Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved] QGraphicsView to fill main window with QT Designer
QtWS25 Last Chance

[solved] QGraphicsView to fill main window with QT Designer

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 14.4k Views
  • 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 Offline
    G Offline
    gkroeger
    wrote on last edited by
    #1

    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
    0
    • D Offline
      D Offline
      DenisKormalev
      wrote on last edited by
      #2

      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
      0
      • G Offline
        G Offline
        gkroeger
        wrote on last edited by
        #3

        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
        0
        • G Offline
          G Offline
          gkroeger
          wrote on last edited by
          #4

          Denis et al:

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

          Thanks.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            gkroeger
            wrote on last edited by
            #5

            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
            0
            • D Offline
              D Offline
              DenisKormalev
              wrote on last edited by
              #6

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

              1 Reply Last reply
              0
              • G Offline
                G Offline
                gkroeger
                wrote on last edited by
                #7

                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
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved