0
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "F:/QGIS/bin/test.py", line 6, in <module>
    img = QImage(QSize(800,600), QImage.Format_ARGB32_Premultiplied)
NameError: name 'QImage' is not defined

I encountered this error when I was trying for Map Rendering and Printing on python console given in QGIS.

1
  • 3
    missing import? Can you show a more complete example that demonstrates the problem so we don't have to guess?
    – BradHards
    Mar 5 '14 at 19:59
5

QImage is in QtGui, so my first thought would be that you need to import PyQt4.QtGui.

So either:

from PyQt4.QtGui import *

Or:

import PyQt4.QtGui

But more information would be helpful if importing PyQt4.QtGui doesn't get rid of the error.

Not the answer you're looking for? Browse other questions tagged or ask your own question.