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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -