Search code examples
qtqdockwidget

Qdockwidget -- floating button on titlebar of qdockwidget


I am using QDockWidget in my GUI and I need to create a slot for the floating button of a QDockWidget so that when I click the floating button of a QDockWidget it maximize it.

Which signal is emitted when I click floating button on an QDockWidget ? I want to trigger a slot where I will make window floating & then maximize it, using this code.

ui->dockWidget_2->setFloating(1);
ui->dockWidget_2->showMaximized();

Please suggest which signal is emitted when i click float button on a QDockWidget ?


Solution

  • http://qt-project.org/doc/qt-4.8/qdockwidget.html#topLevelChanged

    void QDockWidget::topLevelChanged ( bool topLevel ) [signal]
    This signal is emitted when the floating property changes. The topLevel parameter is true if the dock widget is now floating; otherwise it is false.
    

    So you can connect it to a slot that maximizes the widget if topLevel is true