[PyKDE] Typecasting problems with PyQt embedded in Scribus
Jim Bublitz
jbublitz at nwinternet.com
Thu Jun 30 18:29:49 BST 2005
On Thursday 30 June 2005 09:33, Henning Schröder wrote:
> Hi!
>
> Jim Bublitz <jbublitz at nwinternet.com>:
> > [..]
> > wrapinstance and unwrapinstance are covered in the sip docs.
>
> Thanks I will try your C++/Python-mixed solution.
>
> 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)
Jim
More information about the PyQt
mailing list