If you want to use the resource system, is it not that there is a ":/" missing? In my application I use resiurce files like this:
QFile qfi(":/texts/res/usageNotes.txt");
This works:
if(qpm.load(":/img/myImage.jpg"))
{
icon.addPixmap(qpm);
ui->pushButton->setIcon(icon);
}
else ui->label->setText("nincs betöltve");
QIcon icon;
QPixmap qpm;
if(qpm.load(":/img/myImage.jpg"))
{
icon.addPixmap(qpm);
ui->pushButton->setIcon(icon);
}
else ui->label->setText("nincs betöltve");
To copy to clipboard, switch view to plain text mode
Otherwise I have the guess that the absolute path works because the executable file is not generated in the same directory as the code, so the executable file whilst working is trying to find the image on the relative path from itself, where is actually nothing, as there might be even no directory like that.
Bookmarks