PDA

View Full Version : Tab Positions QDockWidgets Show/Hide not remembered! Can't get active tab either!



genjix
25th October 2010, 16:42
Hey,

C++ example (run qmake/make): 5397
Python PySide code: 5398

I'm trying to make a QDockWidget area that rolls in and out when the user mouse-overs (see the start of this video here (http://www.youtube.com/watch?v=8tAASvcrJ78)). To do that I getting all the dock widgets from the window by window.findChildren<QDockWidget*>() and then doing w.setVisible(false) on all of them.

Problem is that it has bugs. If you download, build and run the C++ example above then Qt selects the tab position selected before the current one, and then reselects the last one again and so forth.

Problem is Qt provides no way to a) see the currently selected dock widget tab (so I cannot force it to be re-active).

Are these 2 bugs? What can I do here? :(

genjix
25th October 2010, 23:20
This might give you some idea about what I'm referring about:
http://img229.imageshack.us/img229/4347/screenec.png

genjix
26th October 2010, 08:37
I found the answer:
http://developer.qt.nokia.com/faq/answer/how_can_i_check_which_tab_is_the_current_one_in_a_ tabbed_qdockwidget

EDIT: 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?

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. Although it DOES use QTabBar and I'm able to reset the active tab using that (although I have no way to confirm which QTabBar belongs to which QTabWidget or if at all).

And here is the restoration code:


# --------
for tab in self.activeTabs:
tab[0].setCurrentIndex(tab[1])
self.activeTabs = []

genjix
26th October 2010, 21:41
any ideas?