This is my code, and note that the "image.png" is an image located in the same folder as the source code:
int main(int argc, char *argv[])
{
widget->setFixedSize(500, 500);
widget->show();
label->setGeometry(10, 10, 480, 480);
label->show();
*temp = file->readAll();
pix->loadFromData(*temp);
label->setPixmap(*pix);
return application->exec();
}
int main(int argc, char *argv[])
{
QApplication *application = new QApplication(argc, argv);
QWidget *widget = new QWidget();
widget->setFixedSize(500, 500);
widget->show();
QLabel *label = new QLabel(widget);
label->setGeometry(10, 10, 480, 480);
label->show();
QByteArray *temp = new QByteArray();
QFile *file = new QFile("image.png");
*temp = file->readAll();
QPixmap *pix = new QPixmap();
pix->loadFromData(*temp);
label->setPixmap(*pix);
return application->exec();
}
To copy to clipboard, switch view to plain text mode
This gives me a message saying:
QPixmap::convertFromImage: Cannot convert a null image
What am I missing ?
Bookmarks