[PyKDE] QGLWidget rendering problems

Phil Thompson phil at riverbankcomputing.co.uk
Fri Dec 19 00:31:00 GMT 2003


On Thursday 18 December 2003 8:53 pm, David Boddie wrote:
> On Thursday 18 December 2003 18:29, Phil Thompson wrote:
> > On Thursday 18 December 2003 12:36 am, David Boddie wrote:
> > > Getting this sort of information from a QImage object at the Python
> > > level appears to be difficult since there isn't an equivalent to the
> > > QImage.loadFromData method for saving image data. Wasn't this problem
> > > discussed on this list recently?
> >
> > I'm quite willing to add a toString() method to the sip.voidptr type
> > which will take an argument specifying the number of bytes. I'm less
> > willing to add anything more complicated.
>
> It's an interesting solution, but I'm (slightly more) interested in
> symmetry between the functions which return uchar* and those which take
> uchar* as an argument. For example, the QImage.loadFromData method can take
> a string as an argument so you might expect QImage.bits to automatically
> return a string.
>
> This is obviously going to be more work. Your solution is probably just as
> convenient, and more generally useful.

The problem is '\0' termination. SIP assumes uchar * and char * refer to C 
strings unless the length is also passed as a parameter at the C/C++ level - 
in which case you have to use the /Array/ and /ArraySize/ tags.

To convert in the other direction the "natural" thing to do is implement str() 
of a sip.voidptr, but that would assume a '\0' terminated string. So I will 
have to invent toString() which will allow the explicit length to be 
specified.

Phil




More information about the PyQt mailing list