Qt resource not showing up in static build...
-
Also to be clear.
It does work in statically linked debug version but not in a
statically linked release version?
That is odd.
When you made your statically linkable Qt, you did use release mode? -
@mzimmers
Hi, svg is a normally plugin. maybe it was not compiled in ?
Did you try with a png or a more native image? -
Also to be clear.
It does work in statically linked debug version but not in a
statically linked release version?
That is odd.
When you made your statically linkable Qt, you did use release mode? -
@mrjj not quite: it works in dynamic/debug, but not in static/release. I haven't tried the other permutations yet.
-
Aha! So your debug is in fact dynamically linked. Then do the manual resource initialization as @SGaist hinted!
@kshegunov sorry - I thought I'd made that clear in my OP.
I've added this line to my main (my resource file is called "resources.qrc"):
Q_INIT_RESOURCE(resources);
Still doesn't show, and I'm getting that null pixmap error.
-
Do you have several resources named like that ?
-
@SGaist I'm not sure what you mean by "named like that," but I only have one .qrc file, and it only has two files in it.
Okay, can you grab a screenshot from the resource editor? Unless that path is an alias, then you need to put the image into that folder under the project. I personally always alias the things because it feels quite clumsy otherwise ...
-
So I need a subdirectory in my source folder? I'll try that.
EDIT: just moved logo to a subfolder, rebuilt and now I'm getting an error:
[release/qrc_resources.cpp] Error 1
So I deleted the moved file and re-added it. Still getting the null pixmap error.
-
So I need a subdirectory in my source folder? I'll try that.
EDIT: just moved logo to a subfolder, rebuilt and now I'm getting an error:
[release/qrc_resources.cpp] Error 1
So I deleted the moved file and re-added it. Still getting the null pixmap error.
@mzimmers said in Qt resource not showing up in static build...:
just moved logo to a subfolder, rebuilt and now I'm getting an error:
Not any subfolder, looking at the screenshot you need a folder called
logos
under your project root. Then readd the file and I think it should work. -
@mzimmers said in Qt resource not showing up in static build...:
just moved logo to a subfolder, rebuilt and now I'm getting an error:
Not any subfolder, looking at the screenshot you need a folder called
logos
under your project root. Then readd the file and I think it should work.@kshegunov no joy.
EDIT: put some text in here to separate the pics.
But at least now it's missing from both the debug and release versions...
-
@kshegunov no joy.
EDIT: put some text in here to separate the pics.
But at least now it's missing from both the debug and release versions...
But now your resource tree looks funny, you have two folders named "logos" there ...?
-
OK, I obviously don't know what's going on here. The resource editor requires me to add a prefix before I can add a file. When I add the file, if it's in a subdirectory, that gets prepended to the file name. This is why you're seeing what appears to be two levels of folders.
I don't know how to do this differently.
-
OK, I obviously don't know what's going on here. The resource editor requires me to add a prefix before I can add a file. When I add the file, if it's in a subdirectory, that gets prepended to the file name. This is why you're seeing what appears to be two levels of folders.
I don't know how to do this differently.
Ah, okay. That's why I'm saying it's damn clumsy. Add only a
/
as prefix and then add your file. It should fix the double folder thing. -
Ah, okay. That's why I'm saying it's damn clumsy. Add only a
/
as prefix and then add your file. It should fix the double folder thing.@kshegunov alas, that didn't work, either. You're right, though...this is one awkward interface.
-
@kshegunov alas, that didn't work, either. You're right, though...this is one awkward interface.
You mean it didn't fix the double folder thing or you still can't load the image?
Your resource file should look something like this:
Then you'd load with
:/images/20171022_152431.jpg
. -
Yes my resource file looks similar to yours. The image displays when dynamically built, but not static.
Could you try with a static/debug just for the sake of it, to be honest I'm at a lost as you seem to have done everything right.
-
Static/debug doesn't display the image, either. So I'm doing something wrong with the inclusion of resources into a static build...?
Yes, this would be my best guess. Could you look inside the build folder and see if there's a file
.rcc
named after yourqrc
file? Perhaps it's not linked with the binary for some reason ...