0

I am trying to mimic the behaviour on PyCharm, where there are docks on the edges and, if the user clicks on the tab, it exapnds and collapses the dock to increase the central widget.

I managed to put the tabs on the site, and I can subscribe to the tabBarClicked event to detect QDockWidgets, but I still need to figure out 2 problems:

  1. How to always display a tab on each region where there is a dock (if there is more than 1 dock on that area, the tabs are automatically handled, but if there is only 1 dockwidget, no tabs are shown).

  2. How to keep the tab if I hide the dock (for collapsing the widget).

Any ideas? This is what I got so far. As you can see, the QDockWidget on the bottom does not have a tab, but a title bar.

enter image description here

laurapons
  • 971
  • 13
  • 32
  • You can keep track of dock position by connecting to their [`dockLocationChanged`](https://doc.qt.io/qt-5/qdockwidget.html#dockLocationChanged), and update the contents of each area in an internal dictionary, so that you can always know which docks each area contains, even if its hidden. – musicamante Sep 15 '22 at 09:54
  • I did this already, but does not solve having the tab always visible (on 2 occasions: when there is only 1 dock in place or kipping the tab when hiding a dock) – laurapons Sep 15 '22 at 13:45
  • Oh, now I get it: I thought that you implemented the tab bar on your own, but you're actually using the *tabified* tabs, aren't you? If that's the case, I'm afraid that with the default implementation you cannot show tabs if only one dock exists, and that's because the layout management of QMainWindow (including showing/hiding tabs and their automatic addition/removal on drag&drop) is completely private. **IF** you always intend to use tabified docks, then there could be some possibility using custom QTabBars and a couple of workarounds. – musicamante Sep 15 '22 at 15:57

0 Answers0