[PyQt] Can't create a QImage?

Giovanni Bajo rasky at develer.com
Sun Jun 1 12:58:01 BST 2008


On Sat, 2008-05-31 at 17:47 +0200, Piotr Antoniak wrote:
> Hi! I'm very new to PyQt (just started using it today) and also quite
> new to Qt in general... I have a problem creating a QImage. No matter
> what I do, it creates a null one... here's the output I get after I
> try to create a 10x10 QImage:
> 
>  
> 
> >>> image = qt.QImage(qt.QSize(10,10), 4)
> >>> image.width()
> 0
> >>> image.height()
> 0
> >>> image.depth()
> 0
> 
> 
> The third parameter means the RGB32 format... for some reason, when I
> type qt.QImage.Format_RGB32 there instead, I get the error
> "AttributeError: Format_RGB32". Can someone help me create a QImage?
> By the way, if I replace "qt.QSize(10,10)" with simply "10, 10" the
> result is exactly the same...

There has to be a problem with your PyQt installation, try a newer
version. This is my output:

>>> from PyQt4.Qt import *
>>> img = QImage(QSize(10,10), 4)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: argument 2 of QImage() has an invalid type
>>> img = QImage(QSize(10,10), QImage.Format_RGB32)
>>> img.width()
10

-- 
Giovanni Bajo
Develer S.r.l.
http://www.develer.com




More information about the PyQt mailing list