[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyKDE] Filling QPixmap from C code
From: Phil Thompson <phil () river-bank ! demon ! co ! uk>
Date: 2003-04-16 8:01:33
[Download RAW message or body]
On Wednesday 16 April 2003 8:23 am, Giaco777 wrote:
> Hi PyQters,
>
> first of all I would like to thank Phil for this great RAD environment
> for QT.
>
> In my application I would like a QPixmap generated by PYQt
> to be filled by a C subroutine. My first try would look like this (in
> principal):
>
> Python:
>
> qp=QPixmap(...)
> fillQPixmap(qp) # this is realized in C
>
> C:
>
> // this is the C subroutine which fills QPixmap
> static PyObject *fillQPixmap(PyObject *self, PyObject *args) {
> PyObject * po;
> if(!PyArg_ParseTuple(args, "O", &po)) return NULL;
>
> // interpret object as QPixmap pointer
> QPixmap *pm = (QPixmap*) PyCObject_AsVoidPtr(po);
>
> // do something with pm
>
> Py_INCREF(Py_None);
> return Py_None;
> }
>
>
> Is there a chance that this will work or is there a better solution?
There is no chance that this will work because po is a class instance and the
real C++ pointer is buried deep within in.
You need something like...
// interpret object as QPixmap pointer
int iserr = FALSE;
QPixmap *pm = (QPixmap *)sipConvertToCpp(po,sipClass_QPixmap,&iserr);
if (iserr)
return NULL;
if (pm == NULL)
{
raise_exception_about_None_being_passed();
return NULL;
}
Phil
_______________________________________________
PyKDE mailing list PyKDE@mats.gmd.de
http://mats.gmd.de/mailman/listinfo/pykde
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic