[Interest] Detach widget from QDockWidget

Bo Thorsen bthorsen at ics.com
Mon Jan 20 12:22:43 CET 2014


Den 15-01-2014 18:15, Etienne Sandré-Chardonnal skrev:
> Hi,
>
> In my app, I have tabs in the main window. A dock widget allows setting
> display options for the current tab.
>
> Since each tab may have a different dock widget options layout, I was
> considering the following:
>   - Each tab keeps a QWidget options dialog on its own
>   - When a tab is selected, the main window sets this widget in the dock
> widget.
>
> However, it seems that once QDockWidget::setWidget is used, the given
> widget cannot be detached from it. So it seems I have to recreate a
> widget every time, and reconfigure it.
>
> Any simple idea? Is it possible to detach from a QDockWidget?

You don't have to do that. Use a QStackedWidget instead, add all the 
options "dialogs" (they are pages when it's in stacks) and switch to the 
one that matches your current tab.

If you want to resize the minimum of the stacked widget to the current 
item, you have to explicitly hide the pages that are not currently shown.

Bo.

-- 
Bo Thorsen, European Engineering Manager, ICS
Integrated Computer Solutions. Delivering World-Class Applications
http://ics.com/services



More information about the Interest mailing list