Hello everyone,
I am trying to display an image using QGraphicsView but all I get is a blank window.
Here is the code:
int main(int argc, char *argv[])
{
//does not work either
//QGraphicsPixmapItem *item1 = scene->addPixmap(Pix);
scene->addItem(item);
view.setScene(scene);
view.show();
return a.exec();
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv)
QGraphicsView view;
QGraphicsScene* scene = new QGraphicsScene(QRect(0, 0, 600, 400));
QPixmap Pix("king.png");
//does not work either
//QGraphicsPixmapItem *item1 = scene->addPixmap(Pix);
QGraphicsPixmapItem *item = new QGraphicsPixmapItem(Pix);
scene->addItem(item);
view.setScene(scene);
view.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
I think that I'm missing something obvious, but still I'm unable to find it on my own.
Any suggestions?
Bookmarks