Adding Widgets to QDockWidget without a layout



  • 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?


  • Moderators

    @Andaharoo Set the QDockWidget as parent in those other widgets and position them then manually using for example setGeometry().


Log in to reply