Image from resource never shown
-
Hello,
I have a project (QT 5) with image files put in a resource file.
The resource file is created with QTCreator.
When the program is executed from QTCreator, all images are shown correctly.
When the program is executed ouside QTCreator, the images are not displayed.
The image files are in the same directory as the resource file.
The .cpp and .o files corresponding to the resource are created when building the project.
I put Q_INIT_RESOURCE(images); in the main file.
Here is an exemple :QPixmap pic(":/ok.gif"); QIcon ic(pic); QPushButton* bt = new QPushButton(this); bt->setIcon(pic);I also tried to put the full path of ok.gif, but the result is the same.
I run qmake before building the project.
I spent some hours on forums and tried a lot a solutions, but with no result actually.
If somebody has a solution, it will be great.
Thanks,
Olivier
I also try to put the full path -
Hello,
I have a project (QT 5) with image files put in a resource file.
The resource file is created with QTCreator.
When the program is executed from QTCreator, all images are shown correctly.
When the program is executed ouside QTCreator, the images are not displayed.
The image files are in the same directory as the resource file.
The .cpp and .o files corresponding to the resource are created when building the project.
I put Q_INIT_RESOURCE(images); in the main file.
Here is an exemple :QPixmap pic(":/ok.gif"); QIcon ic(pic); QPushButton* bt = new QPushButton(this); bt->setIcon(pic);I also tried to put the full path of ok.gif, but the result is the same.
I run qmake before building the project.
I spent some hours on forums and tried a lot a solutions, but with no result actually.
If somebody has a solution, it will be great.
Thanks,
Olivier
I also try to put the full path@OlivierDz
I am not sure why it would work from within Creator but not outside. I assume you are running the resource compiler to compile the resources into the executable? When run outside, are you executing the same path to the executable as is being used inside Creator?Otherwise I would say deploy correctly to use a Qt application outside of Creator, in case there is an issue.
In your case you should not need
Q_INIT_RESOURCE(images);, just (presumably)QPixmap pic(":/images/ok.gif");. Does that make any difference? -
This could be a plugin issue, specifically the gif plugin to read the image file. How is your application loading the Qt libraries when you run it outside of Qt creator? Have you added it to your path or copied the shared libraries to the same location as your executable?
-
This could be a plugin issue, specifically the gif plugin to read the image file. How is your application loading the Qt libraries when you run it outside of Qt creator? Have you added it to your path or copied the shared libraries to the same location as your executable?
@mchinand
I copied the shared libraries to the same location as my executable.
I tested with Qt5 and Qt6 / Win 7 and Win 10.
Here is the list :
libgcc_s_seh-1.dll
libstdc++-6.dll
libwinpthread-1.dll
Qt6Core.dll
Qt6Gui.dll
Qt6PrintSupport.dll
Qt6Sql.dll
Qt6Widgets.dll
platforms/qwindows.dll
sqldrivers/qsqlite.dllDo I miss one ?
-
@JoeCFD
Here it is :<RCC> <qresource prefix="/"> <file>icone.ico</file> <file>icone.png</file> <file>logo_200.jpg</file> <file>logo_2000.png</file> <file>logo_big.png</file> <file>medal.png</file> <file>ok.gif</file> <file>star.gif</file> </qresource> </RCC> -
When you want to read a gif file not need the Qt gif plugin in imageformats.
-
This could be a plugin issue, specifically the gif plugin to read the image file. How is your application loading the Qt libraries when you run it outside of Qt creator? Have you added it to your path or copied the shared libraries to the same location as your executable?