[PyKDE] C++ to Python Datatypes

Russell Valentine russ at coldstonelabs.org
Mon Oct 13 02:50:01 BST 2003


I'm having trouble sometimes figuring out what Python datatype goes with
the C++ datatype.

An example a 2x2 grayscale QImage:

**C++ Define

QImage ( uchar * yourdata, int w, int h, int depth, QRgb * colortable, int numColors, Endian bitOrder )


How do you know what type to use for uchar *yourdata?

**Python?

grayColorMap = []
for i in range(256):
        grayColorMap.append(QColor(i, i, i).rgb())

buffer = []
buffer.append(255)     #white
buffer.append(0)       #black
buffer.append(255)     #white
buffer.append(0)       #black

image = QImage(buffer, 2, 2, 8, grayColorMap, 256, QImage.IgnoreEndian)


But I get:

Traceback (most recent call last):
  File "./testQColor.py", line 22, in ?
    image = QImage(buffer, 2, 2, 8, grayColorMap, 256, QImage.IgnoreEndian)
  File "/usr/lib/python2.2/site-packages/qt.py", line 439, in __init__
    libqtc.sipCallCtor(123,self,args)
TypeError: Too many arguments to QImage(), 1 at most expected


I am confused. Thanks for any help!


Russell Valentine
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20031013/79cec9a3/attachment.bin


More information about the PyQt mailing list