How to organize moc files into subfolders - qt

My project has modules with identical file and class names. Namespace avoids name conflicts. The object_parallel_to_source option distributes the object files into subfolders so they don't get overwritten, but the moc files are still merged into one place and overwritten. Is it possible somehow to distribute moc files into subfolders, as it works with object files?

Related

Generate doxygen documentation using Qt project file

How can I tell doxygen to (only) use the files that are in my Qt project file when generating the documentation?
Reason for asking: I'm using a folder structure where a 'common' folder holds files that are used by some (not all) Qt projects I'm working on. Like this:
projects
MyProject
common_files
SubProject_A
SubProject_B
Both SubProject folders will have a Doxyfile and both projects will use some files from the common_files folder.
I know one way to achieve my goal (getting the documentation for just the files used in my project) is to manually add all files in the INPUT setting from the doxygen configuration file. But that would mean I'll have to change the Doxyfile every time I add or delete a file to/from my project.
Doxygen should be able to filter the files needed for the documentation from the .pro file. But how?

How do I use classes from files in another directory in R?

I have a bunch of .R files in a directory (classes with inheritance). These files depend on each other.
I need to use these files' classes in a file in a different directory.
Is there a way to directly call their functions/classes from a file in a different location? Maybe by adding them to some kind of path? I was thinking of including each source file manually but they are numerous.

How to automatically include Qt Linguist files into Qt resources for the CMake project?

I use CMake to build Qt project with internatiolization support. Using qt5_create_translation I can create *.ts files into the source directory and *.qm files into the build directory.
I want to reduce the number of files I should to distribute. Storing translation files :/translations/*.qm into the Qt resources is straitforward solution.
But during build process names of the resources are generated automatically and there is no native way to emplace them into the *.qrc file automatically.
How to achieve desired using, say, add_custom_command or something else?
Qt's qrc file is just xml files. Thus you can an external tool to add it.
A pure cmake solution could be:
Create a dummy resource file named #TRANS_FILE#
Add this file to your qrc file
Fetch the name of the translation file into a variable. Don't know how.
Use cmake's configure_file to replace the dummy resource name
Example:
set(TRANS_FILE ${NameOfTranslationFile})
configure_file(infile.qrc outfile.qrc #ONLY)

How do I filter the "imageformats" plugins that are loaded into my Qt Application by their file extension?

We are developing a framework including a number of EXEs based on Qt libraries. In order for one of the EXEs to correctly load SVG graphics we need to include an ImageFormats sub-directory in our application's main working directory with the qsvg.dll plugin. A problem arises because of the way that our framework's auto-update system works. It downloads an entirely new set of application, library and other files and saves them with their names plus a .new extension. It then renames the old files with a .old extension and completes the upgrade by removing all .new extensions from files names, restarting, and deleting files with a .old extension during application load. The problem is that for some reason, Qt doesn't require files in the ImageFormats directory to have .dll extension names. This means that during application load the qsvg.dll.old file gets loaded by the application and is therefore not deletable. The quickest way to fix this would seem to be if we could filter the names of ImageFormats plugins loaded by Qt, but I can't find a way to do this. Any ideas?

Qt including resource directory structure inside executable

I'm using QWebView to run a web app. There are 650+ files. Placing the web app's directory in the source directory does not result in the executable bundling the directory.
How do I include the entire web app directory so that the executable will be able to render the files.
Note: I have currently added index.html as a resource, and can access it with qrc:// - But since I cannot add the entire directory structure to a qrc (can I?), the executable does not include the other files.
You need to put an XML node into the .qrc file for each file you want to use using the Qt resource system.
This can be done using a simple pre-build script. Take a look at qrcgen. Quoting the blog post behind this link:
The script I created, qrcgen, takes a directory and a prefix, recursively scans the directory and generates a .qrc file with the same name as the directory scanned. It has solved my problem, and I hope it can help others. It is also available via PyPI, just "easy_install qrcgen".
In order to update the .qrc file whenever your directory contens change, you need to include this step into your build process:
For C++/Qt projects, you can add this step in the build configuration in QtCreator or add in your qmake file a system(...) statement. Note that such commands aren't portable in general. (If it's not portable, you can put some operating system conditions around multiple commands.)
For PyQt/PySide projects, I don't know how to do this, but I'm sure you find a solution for this too.

Resources