How to show/hide a whole docking area?



  • Hi,

    My application has a few widgets which are docked to the left docking area of my application. Now, there are times where I wish my central widget would get as much real estate as possible. So, in that context, I wish there I could hide all my docked widgets at once, effectively hiding the left docking area (and not hiding each docked widget individually). Ideally, there would be some kind of a button to the right of my left docking area which, when clicked, would either show/hide the whole left docking area. I have googled around a bit for this, but couldn't find anything useful, but I can't imagine this couldn't be done, so... anyone, any idea?

    Cheers, Alan.



  • Is it really that onerous to iterate and hide()/show() the dock widgets in the area? About three lines of code in a slot attached to a button toggled() signal.
    @
    void setDockVisibility(bool visible) {
    foreach (QDockWidget dock, findChildren<QDockWidget>())
    if (dockWidgetArea(dock) == Qt::LeftDockWidgetArea && !dock->isFloating())
    dock->setVisible(visible);
    }
    @

    May require one or two more to not show() dock widgets that were already hidden when the visibility was last set to hidden. Other than that your options are limited to hacking into QMainWindow's internal layout I think.



  • Thanks, ChrisW67, but ideally I wouldn't show/hide the individual dock widgets (mainly because I have some menu items which I use to show/hide them, so it would mess things up with regards to my GUI 'logic'). No, ideally, it would be the docking area itself which would get shown/hidden upon clicking a button (a button which, ideally again, would be within the docking area).


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.