Results 1 to 2 of 2

Thread: QDockWidget closing detection

  1. #1
    Join Date
    Mar 2008
    Location
    Venezuela
    Posts
    34
    Thanks
    4
    Platforms
    MacOS X Unix/X11

    Red face QDockWidget closing detection

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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDockWidget closing detection

    Quote Originally Posted by danielperaza View Post
    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:

    Qt Code:
    1. XX::XX(...) : QMainWindow(...){
    2. //...
    3. QList<QDockWidget*> docs = qFindChildren<QDockWidget*>(this, QString::null);
    4. foreach(QDockWidget *dck, docs){
    5. QAction *act = dck->toggleViewAction();
    6. someMenu->addAction(act);
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 5
    Last Post: 10th May 2006, 00:20

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.