qrc resources are not available during debug build
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?
Re: qrc resources are not available during debug build
Please prepare a minimal compilable example reproducing the problem.
Re: qrc resources are not available during debug build
main.cpp
Code:
#include <QApplication>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QGraphicsPixmapItem>
int main(int argc, char *argv[])
{
scene.addItem(&item);
view.show();
return a.exec();
}
res.qrc
Code:
<RCC>
<qresource prefix="/images">
<file>sample.jpg</file>
<file>wearepros.png</file>
<file>sample.bmp</file>
</qresource>
</RCC>
Re: qrc resources are not available during debug build
What about the project file?
Re: qrc resources are not available during debug build
Code:
#-------------------------------------------------
#
# 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
Re: qrc resources are not available during debug build
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.
Re: qrc resources are not available during debug build
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.
Re: qrc resources are not available during debug build
Quote:
Originally Posted by
roumor
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?
Re: qrc resources are not available during debug build
thank you wysota.
I re installed Qt completely and it's now working and showing resources.