[PyKDE] PyQt/C++ problem

Alfio Puglisi puglisi at arcetri.astro.it
Tue Jul 1 16:47:01 BST 2003


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












More information about the PyQt mailing list