0

I just cannot get the png image to display, I check that it loads correctly which is does but nothing is displayed on my blank canvases. The third one is meant to display an image. Can someone please have a quick look? Thanks.

QImage * QI = new QImage;
bool Check = QI->load("test.png");
QGraphicsPixmapItem * QII = new QGraphicsPixmapItem(QPixmap::fromImage(*QI));

QRect ImagePanelArea1(0, MenuBarHeight, 
                      ScreenWidth / 3, (ScreenHeight / 2) - MenuBarHeight);
QRect ImagePanelArea2(ScreenWidth / 3, MenuBarHeight, 
                      ScreenWidth / 3, (ScreenHeight / 2) - MenuBarHeight);
QRect ImagePanelArea3((ScreenWidth / 3) * 2, MenuBarHeight, 
                      ScreenWidth / 3, (ScreenHeight / 2) - MenuBarHeight);

QGraphicsScene * QGS1 = new QGraphicsScene(ImagePanelArea1, this);
QGraphicsScene * QGS2 = new QGraphicsScene(ImagePanelArea2, this);
QGraphicsScene * QGS3 = new QGraphicsScene(ImagePanelArea3, this); 
QGS3->addItem(QII);

QGraphicsView * QGV1 = new QGraphicsView(QGS1, this); 
QGV1->setGeometry(ImagePanelArea1); 
QGV1->show();
QGraphicsView * QGV2 = new QGraphicsView(QGS2, this); 
QGV2->setGeometry(ImagePanelArea2); 
QGV2->show();
QGraphicsView * QGV3 = new QGraphicsView(QGS3, this); 
QGV3->setGeometry(ImagePanelArea3); QGV3->show();
Ian Wood
  • 6,515
  • 5
  • 34
  • 73
Kachinsky
  • 573
  • 1
  • 7
  • 20

1 Answers1

1

Are you sure that you item is not outside of your scene QGS3?

QII is at the position (0;0). The QRect of your scene is defined between the point ((ScreenWidth / 3) * 2, MenuBarHeight) and the point (ScreenWidth / 3, (ScreenHeight / 2) - MenuBarHeight).

So, if your image is less larger than (ScreenWidth / 3) * 2, your item will be not visible.

NG_
  • 6,895
  • 7
  • 45
  • 67
Dimitry Ernot
  • 6,256
  • 2
  • 25
  • 37
  • My image is 64x64 pixels, and why would it not be displayed? I mean my scene views have borders on them so I assume the picture will simply need to be scrolled if its larger than them. – Kachinsky Apr 09 '13 at 23:19