Qt Image from resource file -
i'm trying insert image program via resource file, like:
<rcc> <qresource prefix="/"> <file>green.png</file> <file>other files</file> </qresource> </rcc>
and when i'm trying load using qimage or qpixmap, like:
qimage *green = new qimage(":/green.png"); if(green->isnull()) qdebug("null");
i see null message, indicating i'm doing wrong. 1 solution may using absolute path like
"c:\\users\\user\\documents\\project\\green.png",
which works of course, i'd prefer implement using resource file. please give me advice?
all work if png files located in same folder .pro, .qrc, , .cpp files of project.
usually convenient put images special subfolder resources, example. in .qrc line like:
<file>resources/green.png</file>
and in .cpp file:
qimage *green = new qimage(":/resources/green.png");
Comments
Post a Comment