[PySide] Getting existing QMainWindow from hybrid app

Paul Miller paul at fxtech.com
Wed May 23 16:28:15 CEST 2012

I am trying to add a dock widget to my application's QMainWindow, which 
is being created in the C++ part of my hybrid application.

But there doesn't appear to be any way to get the 
QApplication.activeWindow() as a QMainWindow - it always just comes back 
as a QWidget, and therefore has no "addDockWidget" method.

Is there a way to "cast" the resulting top-level QWidget to a 
QMainWindow so I can call it's methods, from the Python side?

(something similar to this was asked back in 2010, and considered a bug, 
but there is no resolution: 

If not, is there a tutorial for adding just enough glue to my C++ app so 
I can expose my own QObject-derived objects to the Python side?

More information about the PySide mailing list