Reputation: 65
When i have this code and copy manually i.png to binary file destination
scene = new QGraphicsScene(this);
QPixmap pixm(qApp->applicationDirPath() + "/i.png");
scene->addPixmap(pixm);
ui->graphicsView->setScene(scene);
Image shows exactly as i want. Now i created resource file images.qrc. Path is set to / and contains only one file i.png. But when i change code to:
scene = new QGraphicsScene(this);
QPixmap pixm(":/images/i.png");
scene->addPixmap(pixm);
ui->graphicsView->setScene(scene);
GraphicsView remains empty. Why?
There is images.qrc
<RCC>
<qresource prefix="/">
<file>i.png</file>
</qresource>
</RCC>
Upvotes: 1
Views: 8851
Reputation: 27611
In order to specify the location of :/images/i.png, I'd expect the resource file to look more like this: -
<RCC>
<qresource prefix="/images">
<file alias="i">images/i.png</file>
</qresource>
</RCC>
Upvotes: 2
Reputation: 22890
":/images/i.png"
assumes that the prefix is images
. Rather use
QPixmap pixm(":/i.png");
Upvotes: 4