View Full Version : qrc resources are not available during debug build
roumor
23rd December 2012, 15:26
Qt 5.0 windows
debug build of my program can't load png image from resources. Widget that supposed to show it stays empty. But when i switch to Release build the image appears just fine.
Also when I use direct path like "c://image.png" then it works too.
I did not modify any build parameters and got fresh installation of Qt 5.0.
do i need to add something to my project settings?
wysota
23rd December 2012, 15:31
Please prepare a minimal compilable example reproducing the problem.
roumor
23rd December 2012, 15:41
main.cpp
#include <QApplication>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QGraphicsPixmapItem>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QGraphicsScene scene;
QGraphicsView view(&scene);
QGraphicsPixmapItem item(QPixmap(":/images/wearepros.png")); //doesn't load during debug build
scene.addItem(&item);
view.show();
return a.exec();
}
res.qrc
<RCC>
<qresource prefix="/images">
<file>sample.jpg</file>
<file>wearepros.png</file>
<file>sample.bmp</file>
</qresource>
</RCC>
wysota
23rd December 2012, 15:44
What about the project file?
roumor
23rd December 2012, 15:54
#-------------------------------------------------
#
# Project created by QtCreator 2012-12-23T13:46:35
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = test3
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
RESOURCES += \
res.qrc
I created project via New Project->Qt gui project. Then replaced main.cpp with my code and left everything else as it was. then did Add new ->qt resource, added prefix and files.
Added after 7 minutes:
I uploaded my project's folder if you like
http://rghost.net/42458531
wysota
23rd December 2012, 16:00
The code looks ok and it works fine for me both in release and debug (on Linux though, however this shouldn't matter).
Please check if the final size of your debug executable changes depending on whether RESOURCES += res.qrc exists in your project file or not.
roumor
23rd December 2012, 16:10
Nope it does not change. it always stays 56kb
release one does change. it is 11kb without "RESOURCES +=" line in pro and 275kb with it.
wysota
23rd December 2012, 16:43
Nope it does not change. it always stays 56kb
Try cleaning the project completely, run qmake and make again. Do you get any warnings during compilation?
roumor
23rd December 2012, 17:23
thank you wysota.
I re installed Qt completely and it's now working and showing resources.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.