Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to show/hide a whole docking area?
Forum Updated to NodeBB v4.3 + New Features

How to show/hide a whole docking area?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 2.8k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    agarny
    wrote on last edited by
    #1

    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.

    RokeJulianLockhartR 1 Reply Last reply
    1
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        agarny
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • A agarny

          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.

          RokeJulianLockhartR Offline
          RokeJulianLockhartR Offline
          RokeJulianLockhart
          wrote on last edited by RokeJulianLockhart
          #4

          @agarny, I have a different use case that cannot be achieved by iterating over an area's children:

          I have two docks in a standard QVBoxLayout, and thus have no use for DockWidgetAreas. Consequently, I want to hide all DockWidgetAreas except the TopDockWidgetArea, which I place the docks inside.

          Currently, my code is the undermentioned:

          class InitialWindow(QMainWindow):
              def __init__(self):
                  central_widget = QWidget()
                  self.setCentralWidget(central_widget)
                  self.addDockWidget(TopDockWidgetArea, toolbar_dock)
                  self.addDockWidget(TopDockWidgetArea, main_content_dock)
                  self.splitDockWidget(toolbar_dock, main_content_dock, QtCore.Qt.Orientation.Vertical)
                  central_layout = QVBoxLayout()
                  central_widget.setLayout(central_layout)
          

          However, the other DockWidgetAreas visible causes the undermentioned:

          1. Padding at the bottom and broken resizability:

            Screenshot_20250212_173606.png

          2. Useless regions:

            Screenshot_20250212_173646.png

          I see AllDockWidgetAreas, which may be useful?

          QtCore.pyi
          class DockWidgetArea(enum.Flag):
              LeftDockWidgetArea   = ... # type: Qt.DockWidgetArea
              RightDockWidgetArea  = ... # type: Qt.DockWidgetArea
              TopDockWidgetArea    = ... # type: Qt.DockWidgetArea
              BottomDockWidgetArea = ... # type: Qt.DockWidgetArea
              AllDockWidgetAreas   = ... # type: Qt.DockWidgetArea
              NoDockWidgetArea     = ... # type: Qt.DockWidgetArea
          

          When using a forum, remember to tag the person you are responding to, in case they are not subscribed to the thread.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            agarny
            wrote on last edited by
            #5

            Thanks @RokeJulianLockhart, but I have (hopefully!) just released the latest version of my Qt application (using Qt 5.12 because I wanted to keep on using QtWebKit, among other things) and I am now using new (more modern, IMO) technologies. I did enjoy my Qt journey though, although not some of the decisions the Qt people made these past few years.

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved