Reputation: 618
I have a qrc file where i added a image (i.png)
The qrc file looks like this
<RCC>
<qresource prefix="/images">
<file>i.png</file>
</qresource>
</RCC>
And this is how I try to use the file
QPixmap pixmap(":/images/i.png");
After some searching around i saw someone said I should chance it to:
QPixmap pixmap(":/i.png");
But this doesnt work ether
Any ideas to why this isn't working?
Upvotes: 1
Views: 1917
Reputation: 6274
The line QPixmap pixmap(":/images/i.png");
is the right one. If it does not work, it is probably because the compiled resource file is either not linked with the binary, or not initialized.
If your resource is loaded from a library, you need to call:
Q_INIT_RESOURCE(resources);
Upvotes: 4