[solved] QGraphicsView to fill main window with QT Designer
I'm new here, so forgive me if this is answered already...
I am trying to create a main window filled with a QGraphicsView that expands and contracts with the window.
I can do this programmatically in the main window constructor as follows:
@theGraphicsView = new QGraphicsView(this);
I can't seem to replicate this using QT Designer?
When I drag a QGraphicsView into the main window, it adds it to the CentralWidget... but it doesn't change size with the window. I have tried various settings of maximum sizes and sizePolicy. I'm probably missing something really obvious, but I am stumped.
Thanks for any suggestions.
You should add it into layout. In QtDesigner you can put QGraphicsView into central widget , than right click on it and layout it horizontally or vertically.
Thanks... I thought that was needed... but all of the layout options are grayed out, both in the popup menu and in the tools->form editor menus?
Denis et al:
Got it! I added a grid layout, then added the Graphics View and all is well.
Well, maybe not... the Graphics View fills the layout, but the layout doesn't fill the central widget when the window is resized.
Try next steps:
Put GraphicsView into centralWidget
Right click on empty space in centralWidget
That did it! Thanks. I had tried to set the layout on the central widget prior to adding the graphics view, but menus aren't active until at least one widget is added.