Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [solved] QGraphicsView to fill main window with QT Designer

    General and Desktop
    2
    7
    13789
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      gkroeger last edited by

      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

      1 Reply Last reply Reply Quote 0
      • D
        DenisKormalev last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • G
          gkroeger last edited by

          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

          1 Reply Last reply Reply Quote 0
          • G
            gkroeger last edited by

            Denis et al:

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

            Thanks.

            1 Reply Last reply Reply Quote 0
            • G
              gkroeger last edited by

              Well, maybe not... the Graphics View fills the layout, but the layout doesn't fill the central widget when the window is resized.

              1 Reply Last reply Reply Quote 0
              • D
                DenisKormalev last edited by

                Try next steps:
                Put GraphicsView into centralWidget
                Right click on empty space in centralWidget
                Layout
                Vertically

                1 Reply Last reply Reply Quote 0
                • G
                  gkroeger last edited by

                  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

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post