Adding Widgets to QDockWidget without a layout
-
wrote on 4 May 2017, 02:45 last edited by Andaharoo 5 Apr 2017, 02:47
How do you add widgets to a QDockWidget? I do it in the designer all the time but in code all I see is a setWidget function. I tried it and it only works with one widget. How can I do this without using a layout? (The default behavior you would expect if you started dragging and dropping widgets into a dock in the designer.) The designer creates a default dockWidgetContents which is a Qwidget and then has a bunch of widgets underneath it. This all seems to imply I need to somehow add widgets to another widget and then add that widget to the dock?
-
How do you add widgets to a QDockWidget? I do it in the designer all the time but in code all I see is a setWidget function. I tried it and it only works with one widget. How can I do this without using a layout? (The default behavior you would expect if you started dragging and dropping widgets into a dock in the designer.) The designer creates a default dockWidgetContents which is a Qwidget and then has a bunch of widgets underneath it. This all seems to imply I need to somehow add widgets to another widget and then add that widget to the dock?
@Andaharoo Set the QDockWidget as parent in those other widgets and position them then manually using for example setGeometry().
1/2