PDA

View Full Version : Catching events for tabBar of tabbed QDockWidget



koosh
16th June 2009, 22:30
I'm using tabbed dock widgets which remain docked to the mainwindow. I want to override the dock widget behavior as follows:

1) clicking the close button on the dock widget title bar shrinks rather than closes the dock window.
2) clicking on the tab when the dock widget is shrunk causes it to expand to normal size.

I've implemented #1 by reimplementing closeEvent() in a subclass of QDockWidget. I then set the minimum and maximum size to 0 and update the geometry. It works fine.

By restoring the min/max size and updating the geometry again I get the widget to restore its original size, manually.

However, I don't know how to catch the mouseButtonPress event on the tab bar for the dock widgets. The event isn't propagated to the QDockWidget itself, and there is no API for getting a handle to the tab bar. I've tried installing an event filter on the dockWidget->parentWidget(), but that seems to be the QMainWindow, not the tab bar.

Any ideas on how to catch a click on the tabBar tabs?

Using Qt 4.5.1

Thx.
-Brian

shentian
16th June 2009, 22:52
Maybe QDockWidget::visibilityChanged works for you?

koosh
16th June 2009, 23:17
Well, almost. Having tried that before without success, I just discovered that the setMinimumSize() must be >0 for these signals to be generated.

However, this only gets generated if the user selects a different tab than the one previously selected. Otherwise, nothing happens. I also can't seem to find a way to unselect all the tabs.

If I click a different tab, then it works as I want, but not if clicking the same tab again.

Thanks for the advice, tho.