How to get code completion for PyQt using Pydev



This is my OLD blog. I've copied this post over to my NEW blog at:

http://www.saltycrane.com/blog/2007/06/how-to-get-code-completion-for-pyqt/

You should be redirected in 2 seconds.



Because PyQt doesn't come with the .py source files which Pydev needs for code completion, you need to add the PyQt modules as a "forced builtin lib". See the following FAQs at the pydev website: http://pydev.sourceforge.net/faq.html#ref_22 and http://pydev.sourceforge.net/faq.html#ref_15
 
Here are the steps:
  1. Go to "Window" -> "Preferences..." -> "Pydev" -> "Interpreter - Python"
  2. In the "Forced builtin libs" section, click "New..."
  3. Type in "PyQt4" and click "OK".
  4. Click "OK" to close the Preferences window.
Note: If you installed PyQt after installing Pydev, you will probably have to update the PYTHONPATH with the path to the PyQt libraries. You can do this easily by "Remove"ing the python interpreter and then re-adding it in again. (For reference, I am using Eclipse 3.2.2, Pydev 1.3.4, Python 2.5.1, and PyQt 4.2.3)

1 comment:

Andrea Grandi said...

Code completion now works fine for me, except for some classes. For example:

if I write: from PyQt4 import

it only shows me two class available: QtCore and QtGui, for example I cannot see QtNetwork, but if I write it by hand, my code execute it without problems.

Any suggestion about this problem?

About

This is my *OLD* blog. I've copied all of my posts and comments over to my NEW blog at:

http://www.saltycrane.com/blog/.

Please go there for my updated posts. I will leave this blog up for a short time, but eventually plan to delete it. Thanks for reading.