Hi,

I have a program which parses through a .txt file containing photo pathnames and then adds them as QGraphicsPixmapItems to a QGraphicsScene. This works correctly but I am unable to get the QGraphicsView to resize to the size of the pixmap so that the whole image is visible.

To do this, I have created a class TrainingDataWindow which subclasses QMainWindow. The class contains a function selectImageSource() that correctly obtains the first pixmap from the .txt file and adds it to the QGraphicsScene. In this function, I have tried multiple ways of calling QGraphicsView::resize(....) in order to make the whole image visible. These methods include:

1.
Qt Code:
  1. view_image->resize(imgScene.itemsBoundingRect().width(),imgScene.itemsBoundingRect().height());
To copy to clipboard, switch view to plain text mode 

2.
Qt Code:
  1. QSize imgSize = img.size();
  2. view_image->resize(imgSize);
To copy to clipboard, switch view to plain text mode 

where view_image is of type QGraphicsView and img is of type QPixmap. Neither of these (or others) have done anything (literally).

Any ideas on how to fix this? If i do need to reimplement resizeEvent() for the TrainingDataWindow class how would this be affected since I designed the program with Qt Designer?

Thanks,
Max