Saltycrane logo

SaltyCrane Blog

Notes on Python, Django, and web development on Ubuntu Linux

    

How to get code completion for PyQt using Pydev

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)

7 Comments — feed icon Comments feed for this post


#1 Andrea Grandi commented on 2008-04-29:

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?


#2 Octavia commented on 2008-10-28:

Thanks for writing this.


#3 Jonathan Blakes commented on 2009-02-22:

nice one


#4 Saatvik commented on 2009-02-26:

For some reason, this still doesn't work for me. I'm using the eclipse that comes with Python(x,y) but I don't think that should make a difference. I've tried adding PyQt4 to both the PYTHONPATH and the Forced Builtin libs and nothing works. Also tried reinstalling PyQt4 without any success.

Thanks


#5 Al Dunstan commented on 2009-05-01:

I've had the same problem as Saatvik. I ran Eclipse from the command line, however, and noticed that it was throwing a ClassCastException when trying to do the completion, trying to cast a SystemASTManager to an ASTManager. I'm going to post the bug at Pydev shortly.


#6 Sebastián commented on 2009-06-21:

Works like a charm, thank you :) I was thinking of using eric4, but now I think I'll stick to Eclipse, the troll at Eric's splashscreen scares the hell out of me.


#7 bswix commented on 2010-05-07:

This works for auto-completion, but I cannot seem to get any call tip for function arguments? Does anyone have this working?

Post a comment

Required
Required, but not displayed
Optional

Format using Markdown. (No HTML.)
  • Code blocks: prefix each line by at least 4 spaces or 1 tab (and a blank line before and after)
  • Code span: surround with backticks
  • Blockquotes: prefix lines to be quoted with >
  • Links: <URL>
  • Links w/ description: [description](URL)
Created with Django | Hosted by Slicehost