Solved Using search paths with Qt Designer
-
Hello,
in a nutshell, I'm looking for a way to set search paths for Qt Designer (see QDir::setSearchPaths) for resources (icons, images, etc.), so that you could use e.g. "icon:edit_object.png" and have the icon loaded and displayed in Qt Designer.
Why I'm trying to do this:
Currently, we are using standard resource files compiled into the binary, which works great with Qt Designer, however they are very cumbersome for our graphical artist who are creating/modifying these resources. Using the resource files means they have to compile the project themselves if they want to test their changes. Instead, they would prefer the resource files be loaded directly from file. This can of course be done, but has 2 major drawbacks:
- The paths to the resources tend to differ between the source tree, the build directory, and the deployed application. I don't see a reasonable way to solve this, other than using search paths.
- Having all the reource files separately is cumbersome for deployment, and doesn't allow e.g. compression of resource files.
My idea was to set up two search paths for resources, the first would have a standard filesystem path (e.g. ../resources/icons/), the other a resource system path (e.g. :/icons/). Thus, if the files were directly present, they would get used, and if they were not present, the compiled resources would get used. This solves every issue quite elegantly. However, the drawback is that Qt Designer won't find the files, and thus won't show the icons/images/etc., and setting the paths has to be done manually (cannot select the file from the resource browser in Designer).
This leads me to my original question, whether it is possible to somehow set the search paths for Qt Designer. If not, I would appreciate any advice on how to solve our situation, maybe there is a solution without search paths that I didn't think of.
Thank you.
-
@andor.patho said in Using search paths with Qt Designer:
cannot select the file from the resource browser in Designer)
You can select from File before entering the res browser.
There are many ways to do this.
What i would do is.
Change app so it can load external resource file (also)
http://doc.qt.io/qt-5/resources.htmlGive Artist a deployment folder with the exe that loads external res next to itself. (if found )
Make special folder say
Imagesinclude the rcc.exe and create a bat file that will compile the files
into the resource.Then artist click on bat file to make new res and then click on .exe to see it.
when happy, he commits the Images folder to the revision system or however you are handling his changes.
Then the programmer simply update his Image folder and get the new/changed icons. -
Thank you for your answer.
@mrjj said in Using search paths with Qt Designer:
You can select from File before entering the res browser.
Yes, you can select the file like this, however this leads to the mentioned problems with paths outlined in point 1. of my original post, e.g. in the source tree the path could be "../../resources/icons/icon.png" (if the icon is used in a subproject), and in the deployed application the path is only "../resources/icons/icon.png".
@mrjj said in Using search paths with Qt Designer:
What i would do is.
Change app so it can load external resource file (also)
http://doc.qt.io/qt-5/resources.html
Give Artist a deployment folder with the exe that loads external res next to itself. (if found )
Make special folder say
Images
include the rcc.exe and create a bat file that will compile the files
into the resource.
Then artist click on bat file to make new res and then click on .exe to see it.
when happy, he commits the Images folder to the revision system or however you are handling his changes.
Then the programmer simply update his Image folder and get the new/changed icons.Yes, this could work. However, this causes the same problem with Qt Designer, because external resources files have to be registered at runtime using QResource::registerResource, so once again, Qt Designer does not have access to them, so it won't show any resources from the external resource file. If no other solution is possible, we will probably do it like this, and learn to live with the missing resources in Qt Designer.
-
@andor.patho
Hi
With creator you simply use compiled into exe (internal)
from the same Image folder.Artist use external
Programmer use internalIts the same actual images. ( preferable controlled by revision system)
The real program will use internal at customer as it wont find external resource.
Maybe I explain it poorly.
-
Hi, it finally clicked, this will work perfectly, thank you!