[PyKDE] Typecasting problems with PyQt embedded in Scribus

Giovanni Bajo rasky at develer.com
Thu Jun 30 23:11:50 BST 2005

Jim Bublitz <jbublitz at nwinternet.com> wrote:

>> But I wonder why the following does not work:
>> ptr = sip.unwrapinstance(qt.qApp.mainWidget())
>> mainWindow = sip.wrapinstance(ptr, qt.QMainWindow)
>> Unfortunately mainWindow is still a QWidget.
> I'm not sure - my guess is that it's because ptr is already typed in
> Python as a QWidget. I've done something similar to get a C++ object
> into Python, but the object was already the correct type - just
> instantiating the wrapper, but no cast involved.
> You might try:
>    mainWindow = sip.cast (ptr, qt.QMainWindow)

We just discussed this on the list. Phil is going to implement a general
solution so that you always get the most derived class Python knows about -- 
QMainWindow in this case.

Giovanni Bajo

More information about the PyQt mailing list