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. QMainWindow layout
Forum Updated to NodeBB v4.3 + New Features

QMainWindow layout

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 4.4k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    somenickname
    wrote on last edited by
    #1

    Hello,

    in my current project, I have got a QMainWindow which, at the moment, only contains QGraphicsView, showing a huge image all over the window.

    What I intend to do is to use only the left 70-80% of the main window for the QGraphicsView, while displaying several other user interface elements (like buttons and line edits) in the right part of the main window.
    Though I'd prefer not to scale the image shown, it would be nice if I could make it scrollable aswell.

    Help would be appreciated.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rahul Das
      wrote on last edited by
      #2

      http://qt-project.org/doc/qt-5.0/qtwidgets/layout.html


      Declaration of (Platform) independence.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tilsitt
        wrote on last edited by
        #3

        more precisely: "stretch factors":http://qt-project.org/doc/qt-5.0/qtwidgets/layout.html#stretch-factors.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kaivolde
          wrote on last edited by
          #4

          .. and more pecisely

          • Place a "dummy-widget" as the central-widget of the MainWindow with setCentralWidget.

          • Install a HBoxLayout on the central widget. Add the first (left) widget with the stretchfactor of 3. Add the second (right) widget a stretchfactor of 1.

          • Now place your other widgets inside of the left-side and right-side-widgets again by using layouts.

          • QGraphicsView already inherits QAbstractScrollArea. So it should be already scrollable.

          • Maybe its a good idea to use a QSplitter as the centralWidget, then the user can adjust the sizes of the left and right area at runtime

          1 Reply Last reply
          0
          • S Offline
            S Offline
            somenickname
            wrote on last edited by
            #5

            Aaaah .. I've been looking for that. Thanks alot.

            One thing: could I simply install the layout on the QMainWindow as well, or do I actually need a dummy widget?

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tilsitt
              wrote on last edited by
              #6

              The layout of a QMainWindow does more than just containing the central widget. It manages the menu bar, the toolbars, the dock widgets, etc. So no, you can't install the layout directly on the QMainWindow, you need the "dummy widget".

              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