I am starting with QGIS python console. Naturally, I came across the PyQGIS Developer Cookbook. While trying to cut my way through it, I encountered a lot of problems with "undefined attributes and names".
Some of them are caused by not importing some library. I had the same problem as described here.
NameError: name 'QImage' is not defined
Even though I imported the PyQt4.QtGui
library. At least, I thought:
Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] on N-PC
## Type help(iface) for more info and list of methods.
help(QImage)
Traceback (most recent call last):
File "<input>", line 1, in <module>
NameError: name 'QImage' is not defined
import PyQt4.QtGui
help(QImage)
Traceback (most recent call last):
File "<input>", line 1, in <module>
NameError: name 'QImage' is not defined
from PyQt4.QtGui import *
help(QImage)
Help on class QImage in module PyQt4.QtGui:
class QImage(QPaintDevice)
| QImage()
| QImage(QSize, QImage.Format)
| QImage(int, int, QImage.Format)
And the help goes on. Why did QGIS fail to load QImage
by the 1st import
command? Or what actually happened here? I am using QGIS 2.4.0, and I get the same issue in 2.0.1.