Hi,

I extended QGraphicsView and, in its constructor, want to load a few pixmaps to display on-screen. To test that the pixmaps are properly loaded, I use qWarning (see below), and from what I can tell in the watch window locals, the image is being loaded. However, past that point, I don't know how to check the data in QLabel if it isn't showing up properly on screen. QLabels are loaded into QGraphicsGridLayout, which is then setLayout into the top-level QGraphicsObject:

Qt Code:
  1. MyViewer::MyViewer(QGraphicsScene *scene)
  2. {
  3.  
  4. QGraphicsGridLayout *layout = new QGraphicsGridLayout;
  5. img_board.resize(8);
  6. for (int i = 0; i < 8; ++i)
  7. img_board[i].resize(8);
  8. for (int j = 0; j < 8; ++j) {
  9. for (int i = 0; i < 8; ++i) {
  10. int index = 8*i + j;
  11. char buffer[200];
  12. QString qindex = itoa(index, buffer, 10);
  13. QString filename(qApp->applicationDirPath() + "/img/");
  14. filename += qindex;
  15. filename += ".png";
  16.  
  17. QPixmap qimg;
  18. if (qimg.load(filename))
  19. qWarning("Failed to load target image");
  20.  
  21. img_board[j][i] = new QLabel;
  22. img_board[j][i]->setPixmap(qimg);
  23. QGraphicsProxyWidget* pixwidget = scene->addWidget(img_board[j][i]);
  24. layout->addItem(pixwidget, i, j + 1);
  25. }
  26. }
  27. QGraphicsWidget* form = new QGraphicsWidget;
  28. form->setLayout(layout);
  29. scene->addItem(form);
  30. setWindowTitle(tr("TESTING"));
  31. resize(800, 600);
  32. form->show();
  33. }
  34.  
  35. .....
  36.  
  37.  
  38. int main(int argc, char *argv[])
  39. {
  40. QApplication app(argc, argv);
  41. MyViewer window(scene);
  42. window.show();
  43. return app.exec();
  44. }
To copy to clipboard, switch view to plain text mode 

The application builds and runs, but the window is just one large white box. I tried digging into img_board as well as layout in the debugger, but the values are a bunch of addresses, with nothing I can use to verify that I properly loaded the pixmap. However, the warnings have stopped, so loads are working, I think.

Thanks for your help!