I want an image to be shown in the same window if I click on a button. But the image can't be found, no matter if it is in the same directory or I write down the whole path. I saw several ways to integrate a picture and thought this was the best one:
MyApp::MyApp(QWidget *parent)
: QWidget(parent)
{
QPushButton *button = new QPushButton("&Randomize!");
gitterlayout->addWidget(button, 5, 0);
connect(button, SIGNAL(clicked()), this, SLOT(Randomizer()));
}
void MyApp::Randomizer()
{
QLabel* bild = new QLabel;
QPixmap pixmap("question.png"); // the important part, the picture is in my project folder
if(!pixmap.isNull())
{
bild->setPixmap(pixmap);
bild->show();
}
else
{
qDebug() << "Cannot find picture"; // I always get this message
}
/* I want this question image to appear because once you click on the button,
a text will be copied to the clipboard and you can't see it until you paste it
(I left it out for this topic) */
}
If I use QPixmap pixmap("C:/myproject/question.png");
(the full path) It doesn't work as well.