Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
My QGraphicsView will not resize
krosseland last edited by
I have a simple Widget containing only a QGraphicsView where I display an image using scene->addPixmap ...
When I drag in the main window I want the QGraphicsView to expand. I have in design mode set the vertical and horizontal size preference to Expanding. However, it does not expand when I make the main window bigger.
Is there a simple way of resizing the QGraphicsView when I make the main window bigger?
You need to put the graphics view in a layout. After you drag the graphics view to the main window select main window and click one of the layout icons on the top toolbar (the blue dots or bars icons) or use a shortcut (CTRL+L).
Setting a size policy only works when a widget is inside a layout, but for a single element it does nothing. It only matters if there are more widgets in the same layout. Then the policy defines how much space each widget gets in relation to others.