PDA

View Full Version : Resource Problem?



poporacer
25th September 2010, 17:22
I have a Qlable that I want to set a picture to. I want the picture to be embedded in the executable. I am using Creator to build this app. I think I might be creating the resource file incorrectly. From my searching to do what I want, the steps are:
1. Create a .qrc file with the files you want included.
2. Reference your .qrc file in the .pro file
3. then you should be able to access the files and they will be embedded.

So I created a .qrc file. I used notepad and indicated the file and saved it as graphics.qrc

<RCC>
<qresource>
<file> MainPic.jpg </file>
</qresource>
</RCC>
The picture is in the same folder as the graphics.qrc file
Then in my .pro file I added
RESOURCES = graphics.qrc

When I build I get an error: [debug/qrc_mxtrainer.cpp] Error 1

What am I doing wrong?

Lykurg
25th September 2010, 17:31
please post the real error message where it says what wrong. Have you also a qrc named mxtrainer?

poporacer
25th September 2010, 17:58
OOPS, I typed in the code as an example but not the actual code, the actual RESOURCES line read RESOURCES = mxtrainer.qrc. But I seemed to have found the problem. Here is what worked for me in case anyone else is having the same problem. In Creator you have to go to "file"/"New File or Project"/QT/QT Resource File and create your resource file there. I had to then add a prefix...it entered "/new/prefix1" by default and then you can add files. I could not find any documentation on this part of Creator. You can keep adding prefixes and it adds /new/prefix2... /new/prefix3. What is the purpose the index and why different indexes? After the resource is added you can just go to the QLable properties and set the pixmap to the file you want...Not too difficult if you know how it is done...but difficult if you don't know all the steps! Is this the proper way to do this or is there a better way?