[PyKDE] PyQt/C++ problem

Alfio Puglisi puglisi at arcetri.astro.it
Thu Jul 3 16:46:00 BST 2003


Hello,
I received no answer but, just in case someone has the same problem, I
found the solution:

I had PyQt build with the default multithreaded QT library, but for some
reason the C++ extension module was linking with the non-multithread
version. Now I changed this, and everything works.

Ciao,
Alfio


On Tue, 1 Jul 2003, Alfio Puglisi wrote:

>Hello,
>hoping that this is not into a FAQ somewhere, but I searched around
>without finding much...
>
>I cannot get my python program (with PyQt modules) and a C++ extension
>module to use the same QT objects. Here's what I wrote:
>
>----------------------------
>#!/usr/bin/env python2
>
>import sys
>import qt
>import qtnetwork
>
>app = qt.QApplication(sys.arg)
>
>## This is the C++ module
>import pixelview
>pixelview.start()
>--------------------------
>
>now in the C++ source, after the required <Python.h>, <qwidget.h> etc I
>try to do some QT stuff:
>
>QPixmap *temp = new QPixmap(10,10,-1);
>
>the program compiles OK, but I get the infamous error:
>
>- must construct a QApplication before a QPaintDevice
>
>But i DID construct a QApplication. The C++ module does not seem to find
>it. They seem to be on different namespaces. For example, this function:
>
>---- Python ----
>pixelview.redraw( self.viewer.winId())
>
>---- C++  ----
>if (!PyArg_ParseTuple( args, "l", &winID))
>	return NULL;
>QWidget *w = QWidget::find(winID);
>
>always places NULL into w, even if the window ID passed is a valid handle
>to some widget returned by the PyQt winId() function.
>
>Note that the function declaration were embedded in an extern "C" block,
>as usual for Python extensions. I suspect this is some kind of C/C++
>mismatch, but I cannot get at the precise point of failure.
>
>Versions:
>python2-2.2-2
>PyQt-x11-gpl-3.5
>sip-x11-gpl-3.5
>
>Thank you in advance for any help.
>
>Ciao,
>Alfio
>
>
>
>
>
>
>
>
>
>_______________________________________________
>PyKDE mailing list    PyKDE at mats.imk.fraunhofer.de
>http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
>





More information about the PyQt mailing list