5

I am developing a tool which will have some variable sized windows. I am able to achieve this using the QSplitter horizontal & vertical. Please see attached image.

Now, how to make these individual windows detachable/maximize/close? How can I add cross markers at the top-right-corner of each window so that they can be closed maximized or detached from there? Just like this link :--

http://vector.com/portal/medien/ecu_testing/tae/test_automation_editor.png

enter image description here

huysentruitw
  • 27,376
  • 9
  • 90
  • 133
user1870619
  • 177
  • 1
  • 6
  • 12

2 Answers2

6

You're looking for the QDockWidget class:

The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-level window on the desktop. QDockWidget provides the concept of dock widgets, also know as tool palettes or utility windows. Dock windows are secondary windows placed in the dock widget area around the central widget in a QMainWindow.

Check out this example

Carsten
  • 11,287
  • 7
  • 39
  • 62
huysentruitw
  • 27,376
  • 9
  • 90
  • 133
  • thanks .. is it possible to do this with QT creator.. actually i am not able to -- combine qdockwidget in the lay out as shown in my attached picture using qt creator ? – user1870619 May 02 '13 at 10:51
  • You can create each child window as a `QDockWidget` using the designer. But I think you'll need code to add them to the main window. To create a `QDockWindow`: *File > New > Qt > Qt Designer From Class > Widgets/QDockWidget*. Then in `MainWindow` constructor: `MyDockWidget* dock = new MyDockWidget(this); addDockWidget(Qt::RightDockWidgetArea, dock);` as in the example. – huysentruitw May 02 '13 at 11:27
  • got the point i will try this... last one ... do we have to specify the default position for each window ? – user1870619 May 02 '13 at 11:46
  • I think so yes. When you call `addDockWidget`, you need to pass the area. And before you ask your next question, you can dock your `QDockWidget` derived widget programmatically with `dock->setFloating(false);` :) – huysentruitw May 02 '13 at 11:55
0

In 2021, there is KDQDockWidget, an apparently much better Qt docking framework with both commercial and open source licenses.

The site lists the following advantages:

  • It provides advanced docking that QDockWidgets doesn’t support.
  • The layouting engine honors min/max size constraints and some size policies.
  • Supports PySide2 bindings.
  • Clean codebase.
  • Supports lazy separator resize.
  • You can reorder tabs with the mouse.
  • Supports partial layout save/restore, affecting only a chosen sub-set.
  • Allows double clicking on title bar to maximize.
  • Allows double clicking on separator to distribute equally.
  • Shows close button on tabs.
  • Allows you to make a dock widget non-closable and/or non-dockable.
  • Provides an optional maximize button on the title bar.
  • FloatingWindows can be utility windows or full native.
user118967
  • 4,895
  • 5
  • 33
  • 54