Recources in static lib problem
-
wrote on 5 May 2014, 11:44 last edited by
I've got an application. It uses class from static lib. In that class was reiplemented painEvent and it use some images which is in the resources of static lib. When I use class in apllication I have no image on screen and got the message "Image is a null image". What I'm doing wrong ?
-
wrote on 5 May 2014, 11:47 last edited by
The resources of a library cannot be loaded automatically. Load the resources using Q_INIT_RESOURCE.
-
wrote on 5 May 2014, 12:11 last edited by
bq. The resources of a library cannot be loaded automatically. Load the resources using Q_INIT_RESOURCE.
I try it. But it doesn't help.
-
wrote on 5 May 2014, 12:15 last edited by
Here is some code in class of static lib:
@ pressed.insert("ledsOff", QImage("qrc:/buttonImage/Resources/ButtonPressed.png"));
pressed.insert("redLed", QImage("qrc:/buttonImage/Resources/ButtonPressed_redLed.png"));
pressed.insert("greenLed", QImage("qrc:/buttonImage/Resources/ButtonPressed_greenLed.png"));
pressed.insert("ledsOn", QImage("qrc:/buttonImage/Resources/ButtonPressed_greenRedLed.png"));@And in main file of application:
@Q_INIT_RESOURCE(sxConsoleButtons);
QApplication a(argc, argv);@I use this class in designer when promote one of the PushButtons to my class.
-
wrote on 5 May 2014, 13:21 last edited by
I believe you cannot create resources before the QApplication object in main() has been created. Try switching those two lines in your main.
-
wrote on 6 May 2014, 13:13 last edited by
bq. I believe you cannot create resources before the QApplication object in main() has been created. Try switching those two lines in your main.
Nope. I tried - there is no effect.
-
wrote on 6 May 2014, 13:19 last edited by
Have you verified that you can get the resource with that name within the static library? The "qrc:/" looks strange to me.
-
wrote on 7 May 2014, 05:04 last edited by
I change it to this: @pressed.insert("ledsOff", QImage(":/buttonImage/Resources/ButtonPressed.png"));
pressed.insert("redLed", QImage(":/buttonImage/Resources/ButtonPressed_redLed.png"));
pressed.insert("greenLed", QImage(":/buttonImage/Resources/ButtonPressed_greenLed.png"));
pressed.insert("ledsOn", QImage(":/buttonImage/Resources/ButtonPressed_greenRedLed.png"));unpressed.insert("ledsOff", QImage(":/buttonImage/Resources/ButtonUnpressed.png"));
unpressed.insert("redLed", QImage(":/buttonImage/Resources/ButtonUnpressed_redLed.png"));
unpressed.insert("greenLed",QImage(":/buttonImage/Resources/ButtonUnpressed_greenLed.png"));
unpressed.insert("ledsOn", QImage(":/buttonImage/Resources/ButtonUnpressed_greenRedLed.png"));@ but still can't get images. But if I use it without static lib it works fine. Maybe I need to do something else ? Some project settings in Visual Studio or any other ideas ? -
wrote on 7 May 2014, 06:57 last edited by
sxConsoleButtons is exactly the name of your qrc file in the static lib?
Beyond that, I'm afraid I'm stumped. I have project both with MinGW and Visual Studio that use static libs and resources, and it works.
-
wrote on 7 May 2014, 07:27 last edited by
sxConsoleButtons.qrc is actually it's name;
1/10