On Tuesday 05 October 2010, 13:42:45 Knacktus wrote: > 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.
Hi Jan, the reason, that you cannot find anything related is most probably due to the concept of dock widgets in the sense of auxiliary widgets, where current focus from the application POV doesn't make much sense. But that isn't a problem, just reimplement focusInEvent and focusOutEvent in the tree views (or the container widget, you set with QDockWidget.setWidget()). Then track focus changes within the event handlers, which might send custom signals to your main widget or some such.. Hth, Pete _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt