PyQt4 names showing as undefined in eclipse, but it runs fine
Question: I am using Eclipse 3.7.1 with the latest PyDev add-in for Python coding. I am
using PyQt4. At the top of my file I have:

    
    
    from PyQt4.QtCore import *
    from PyQt4.QtGui import *
    

In addition, I have the PyQt4 tree included in the Project Explorer listing.
However, eclipse still thinks the names like QMainWindow are undefined. The
code runs fine. How may I get eclipse to recognize those names.

Thanks


Answer: PyQt is actually a wrapping of C++ Qt libraries. So they are not `.py` files
and PyDev can't analyze them to get what is in them. You need to add `PyQt4`
in the [Forced Builtins](http://pydev.org/manual_101_interpreter.html#id1)
tab, so that PyDev can use a Python shell to "look into" those libraries and
know what is in them. That will also give you code-completion for PyQt.

Apart from that, it is usually not a good practice to use `from foo import *`.
You'll be importing everything inside your namespace and you wouldn't know
which is coming from where. Moreover you might have name clashes that mask
each other. Though it is unlikely with PyQt, still I'd suggest you get used to
`from PyQt4 import QtGui, QtCore` and reference classes like
`QtGui.QMainWindow`.

