[solved] QGraphicsView to fill main window with QT Designer



  • Hi:

    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);
    setCentralWidget(theGraphicsView);@

    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.

    Glenn



  • 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.



  • Denis:

    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?

    Glenn



  • Denis et al:

    Got it! I added a grid layout, then added the Graphics View and all is well.

    Thanks.



  • 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
    Layout
    Vertically



  • 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.

    Thanks again.
    Glenn


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.