[PyKDE] MFC w/PyQT

Phil Thompson phil at riverbankcomputing.co.uk
Mon Mar 7 13:43:14 GMT 2005


>
> We have an application that uses PyQt to generate QT dialogs that are
> intended to be children of an MFC application.  There doesn't appear to
> be a simple way to specify a parent window for the QT dialog (or
> QApplication object) from outside of Python.  So, what happens is that
> when the QT dialog appears, it sets its parent to the desktop window
> forcing the windows taskbar to show the dialog as a separate
> application.

How would you do it in C++? If you have an address of an MFC parent
available you can turn it into a pseudo-QWidget using sip.wrapinstance()
and use it as the parent.

> On a related note, when PyQT is used to display the dialog AND the MFC
> application initializes its own QApplication via the MFC Migration Kit,
> the application will crash after the QT dialog is closed.  From what I
> can tell, PyQT and the Migration Kit are sharing the same global qApp
> variable which is being set to NULL after PyQT returns.
>
>
>
> It would seem that a good solution to these problems would be to somehow
> give PyQT a QApplication object to use or tell it to use the current
> global qApp object (if that's possible).

It's your application which is creating the QApplication instance, PyQt
doesn't. If an instance has already been created, then just use qApp
(although you won't have access to any of QApplication's protected
methods).

Phil




More information about the PyQt mailing list