[PyKDE] embedded pyQt question

Phil Thompson phil at riverbankcomputing.co.uk
Tue Feb 1 11:40:58 GMT 2005


> Hi, i'm new to the list and i want to know some things:
>
> I've coded a C++ app with Qt and  embedded Python inside, all works
> greats.
> I've also made a script editor that catch python's stdin/stdout, where I
> dynamic-load pyQT.
> Just perfect...
>
> I can make a widget class and call its show() method to make it appear, no
> need to create a QApplication instance (fantastic).
>
> - How can I make a pyQt's Widget a child of my own C++ Qt app ?

You need to call QWidget's reparent() method. You can either do it in
Python or in C++...

- pass the address of the C++ parent into Python, use sip.wrapinstance()
to convert it to a Python object and call QWidget.reparent(), or...

- in Python extract the address of the C++ child using
sip.unwrapinstance(), pass it to C++ as a Python int object, convert it to
a C++ long, cast it to a QWidget pointer, and call QWidget::reparent,
or...

- pass the Python objetc to C++, convert it to a void * using
sipConvertToCpp(), cast it to a QWidget pointer, and call
QWidget::reparent().

> - The app is coded with Gnu/Linux, have I a chance that it works as well
> under windows ?

There's always a chance ;)

Phil




More information about the PyQt mailing list