QMainWindow layout
-
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.
-
-
more precisely: "stretch factors":http://qt-project.org/doc/qt-5.0/qtwidgets/layout.html#stretch-factors.
-
.. 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
-
-
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?