[PyQt] Newbie: get one of several QDockWidgets to perform action on

Knacktus knacktus at googlemail.com
Tue Oct 5 12:42:45 BST 2010


Hi everyone,

I'm kind of stuck to find the best approach for handling multiple 
dockwidgets.

Imagine this case: I have a QMainWindow with two QDockWidgets. Each 
QDockWidget contains one QTreeView. Now I'd like to implement a button 
"Expand all" that calls a method "expand_all()" which in turn triggers 
the ExpandAll slot of the QTreeView which is active.

I think I need to identify the QDockWidget, which had focus when I 
pressed the button. I've tried the following approaches:

1) qApp.hasFocus() in my "expand_all()" method --> didn't work, gives 
the focus of the button I pressed

2) qApp.activeWindow() --> didn't work, gives the QMainWindow

Overall, I have a bit of a lack of understanding what's "active" and 
"focus" means in the context of QDockWidgets. Hints to documentation is 
appreciated.

Thanks in advance and cheers,

Jan


More information about the PyQt mailing list