Working with several QDockWidgets
-
Yeah I don't mean when the dock widget can be seen, but I mean when the dock widget is the selected one on top in a set of tabs.
I wrote this "small example (click here":http://www.qtcentre.org/attachment.php?attachmentid=5397&d=1288020905 - run qmake/make) to show what I mean. Just click show/hide button and notice your currently selected tab position. Is this a Qt bug?
-
"This":http://bugreports.qt.nokia.com/browse/QTBUG-3420 is the closest bug I could find. Seems QDockWidgets are rather sparse in their api so far :) No way to see who's on top, get the tab orderings, find the layout of several dock widgets in the same area :)
-
How can I see if a QDockWidget belongs to a particular tab bar?
EDIT: this "http://doc.trolltech.com/4.7/qtabwidget.html":http://doc.trolltech.com/4.7/qtabwidget.html
(see indexOf(widget))EDIT2: Or not. Spoke too soon!!! QDockWidgets use QTabBar but they don't use QTabWidget! So how am I meant to see which QDockWidget belongs to which QTabBar so I can restore the state? Very frustrating :(
Here is my saving code (saving tab positions)
@ tabWidgetsAll = self.parent().findChildren(QTabWidget, None)
# tab widgets which contain QDockWidget
tabWidgets = []
if len(tabWidgets) > 0:
print 'yay'
for w in widgets:
for tab in tabWidgetsAll:
if tab in tabWidgets:
continue
if tab.indexOf(w) != -1:
tabWidgets.append(tab)
for tab in tabWidgets:
self.activeTabs.append((tab, tab.currentIndex()))@In that snippet 'yay' is never printed, indicating that no QTabWidget's exist and that QDockWidget doesn't use that for tabifying itself.
And here is the restoration code:
@ for tab in self.activeTabs:
tab[0].setCurrentIndex(tab[1])
self.activeTabs = []@ -
Can Qt add a QMainWindow::setDockAreaVisible(Qt::DockWidgetArea area, bool visible) to their API?
Looking at:
http://qt.gitorious.org/qt/qt/blobs/4.7/src/gui/widgets/qdockarealayout_p.h
It looks like a trivial change:
add to@
class QDockAreaLayout
{
QDockAreaLayoutInfo hiddenDocks[4]; // hidden dock windows
bool dockHidden[4]; // initialise to false, false, false, false on initialiser
};
QDockAreaLayout::setVisible(QInternal::DockPosition pos, bool visible)if (!visible) {
// copy
hiddenDocks[pos] = docks[pos];
dockHidden[pos] = true;
// clear the dock widget area
docks[pos].clear();
} else {
docks[pos] = hiddenDocks[pos];
}
@And add to QMainWindow::setVisible(area, bool) which does:
layoutState.dockAreaLayout.setVisible(toDockPos(area), bool);
invalidate();Hiding/showing a sidepanel is such a common use-case :) This is a really needed feature.
I made a "bug report here":http://bugreports.qt.nokia.com/browse/QTBUG-14725
-
[quote author="genjix" date="1288186847"]Where can I ask whether it would be accepted if the code worked nicely?[/quote]
Could start with a feature request at "http://bugreports.qt.nokia.com":http://bugreports.qt.nokia.com. Or find the developers on the #qt-labs IRC channel on irc.freenode.net for a chat.