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

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to