View Full Version : QDockWidget closing detection

16th April 2008, 16:23
Hi. I want to use a QDockWidget in my QMainWindows application. I have a menu whose actions show the QDockWidget into the main GUI, when an action is checked, the wiget is shown and when it's unchecked the widget is hidden. I want to keep synchronization between the widget's visibility state and the check/uncheck action of the menu so that when an user clicks onto the QDockWidget's close button, the action is unchecked; but so far, I have not been able to find any signal fired by a QDockWidget in order to detect that is hiding its GUI, and so I can execute a slot that unchecks the action in the menu.

QDockedWidget::toogleViewAction () returns a pointer that I haven't been able to repoint to an uic generated action. Do I have to add this pointer to the menu manually? or is there any other way to avoid manually overwritting the uic generated code?.

16th April 2008, 16:28
Do I have to add this pointer to the menu manually?
Yes, you have to manually add it to the menu. Or semimanually - you can query for all dock widgets, their toggle actions and add them to some menu, for instance like so:

XX::XX(...) : QMainWindow(...){
QList<QDockWidget*> docs = qFindChildren<QDockWidget*>(this, QString::null);
foreach(QDockWidget *dck, docs){
QAction *act = dck->toggleViewAction();