2011/7/29 Sam Quinan <[email protected]>:
> Hey,
>
> The documentation lists a constructor for setting the colortable for a
> indexed QImage but doesn't specify what is supposed to be passed in...
>
> http://www.pyside.org/docs/pyside/PySide/QtGui/QImage.html#PySide.QtGui.PySi
> de.QtGui.QImage.setColorTable
>
> The corresponding Qt function takes a QVector<QRgb>, but there does not
> appear to be a QVector structure in PySide...
>
> http://doc.qt.nokia.com/latest/qimage.html#setColorTable

QVector is (like QList) typically wrapped as a standard Python list.
Whenever you read QVector or QList in the C++ documentation, try a
Python "list" in PySide.

> Can somebody tell me what the correct way to create a color table for an
> indexed QImage using PySide is?

from PySide import QtGui
image = QtGui.QImage(width, height, QImage.Format_Indexed8)
colortable = [qRgb(i,i,i) for i in xrange(256)]
image.setColorTable(colortable)

This creates an indexed QImage with a standard grayscale color table.

Hoping to have helped
Sebastian
_______________________________________________
PySide mailing list
[email protected]
http://lists.pyside.org/listinfo/pyside

Reply via email to