PDA

View Full Version : Qt Resource images not showing while executing



sayan275
6th September 2018, 15:09
I'm also facing the issue of resource images not visible when the app is running. I have a plugin-based architecture. Lets say,

NavControls, a staticLib, in which we have the icons on buttons.
The NavControls.lib is used by a Plugin (VIEWERSHARED_EXPORT). I added it in the .pro of the Viewer Plugin

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../Deploy/bin/release/ -lNavControls
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../Deploy/bin/debug/ -lNavControls

INCLUDEPATH += $$PWD/../NavControls
DEPENDPATH += $$PWD/../NavControls
This Viewer plugin implements an Interface.
Finally, I load the plugin in the app, by QPluginLoader class..
The plugin loads without any warnings, but the images are missing on the navControl's buttons.

Please suggest what I'm missing!!

Thanks,
Sayan

d_stranz
7th September 2018, 01:03
You probably need to put the Q_INIT_RESOURCE() macro in main() following the declaration of your QApplication object:



Q_INIT_RESOURCE( name-of-lib );


Where "name-of-lib" is the file name of your static library, without quotes and without the .lib extension. This macro tells Qt to load the resources from the library so they can be used in the app.

ChrisW67
8th September 2018, 09:24
It is also possible you not have the necessary Qt image format plugins deployed.