1

I like the default handling/layout that adding a dock widget to the main window with addDockWidget() provides. Specifically the following:

  1. Uses a QSplitter (I assume) which allows user to resize 2 dock widget and central widget.
  2. Cannot shrink the dock widget below it's minimum size hint.
  3. When dragging the size of the entire window the dock widget stays it's original size (i.e. it's different than dragging the splitter). Thus, the central widget grows when dragging the entire window instead of both dock and central widget growing.

I'd like to mimic this behavior, but on a QDialog since I can't just call addDockWidget(). I'm not really concerned about being able to drag the dock widget around and drop it on other corners, etc. I just want a QLayout setup that can do the above 3 things.

durden2.0
  • 9,222
  • 9
  • 44
  • 57
  • 1
    Why not use a `QMainWindow` instead of a `QDialog`? You can open as many `QMainWindow`s as you want. – D K Jan 31 '12 at 22:16
  • That's a good point. Are there any downsides to having multiple main windows, especially open at the same time? – durden2.0 Feb 01 '12 at 15:15
  • This has a good discussion of main window vs. dialogs, http://stackoverflow.com/questions/1442128/multiple-windows-in-pyqt4 – durden2.0 Feb 01 '12 at 15:17
  • Both `QMainWindow`s and `QDialog`s are `QWidget`s. You shouldn't notice any difference in performance between the two. – D K Feb 01 '12 at 15:23
  • I guess I'll post it as an answer then. – D K Feb 01 '12 at 15:27

1 Answers1

0

You can use a QMainWindow instead of a QDialog in order to get dockwidget functionality for a dialog. You should not notice any difference in performace between QMainWindow and QDialog.

D K
  • 5,530
  • 7
  • 31
  • 45
  • I'm really not sure why I thought there could only be a single QMainWindow for each application. I guess I was confused with QApplication or something. – durden2.0 Feb 01 '12 at 19:29
  • You can even put a `QMainWindow` inside of another widget. – D K Feb 02 '12 at 00:44