Intellisense does not work for my Qt application. What's wrong?

When writing code that uses the class generated from a ui file, the
intellisense does not appear to list the functions for it.

There are several reason why this happens:

1. You are currently in the function body in a slot. The VS intellisense
parser gets confused by the slot keyword in the header file and stops
therefore working. As an easy workarround for this just place a ‘;’ behind the
slots declaration, e.g.:

public slots:;

  1.     void mySlot();
  2.  
  3.  

2. The class/struct is not directly included. Sometimes the completion on e.g.
a push button object does not work since you included . For compilation
it’s of course perfect, but intellisense may not work correctly with this
information. Try to include instead/in addition.

3. The C++ source code has not been generated yet. Intellisense works only on
C++ code, but when designing a form there is no C++ code directly involved.
The C++ code is generated by uic which must be run after the ui file is saved.
So, whenever you added or removed an item from the form you have to run uic on
it. This can easily be done by opening the context menu for the ui file in the
solution explorer and clicking on compile. Another, more comfortable, way of
doing this is enabling the AutoRunUic property in Tools|Options|Qt|General
options page. This basically saves the form and runs uic whenever you leave
the form editor.

4. Make sure you open Visual Studio using the command prompt provided with Qt
in the Start menu if you are using the binary package or from a command prompt
that has the environment set correctly if you are using the source package.

If it’s only happening with a specific project, then try deleting (or
renaming to be safe) the .ncb and .suo file for that project. These will be
regenerated when the project is opened and built, respectively, and could help
if the problem is due to some sort of corruption in those files.

2 comments

August 21, 2010

Picture of Deleted Member # 4a2 Deleted Member # 4a2

Robot Herder

It would be good to have such tips for Qt creator too

September 2, 2011

Picture of bholland314 bholland314

Lab Rat

I have a similar problem. For the most part the intellisense works. I have all the include and project settings as far as I know. But for some reason it does not work on any QPainter objects. Why is this?

I am using VS2008 Professional on Windows 7 with the Qt Addin.

Solved it: U need to add the specific folders to your VC++ Include directory. I added C:\\Qt4.70\\include\\QtGui and intellisense worked for QPainter and QBrush.
Just adding C:\\Qt4.70\\include does not guarentee recursion into the below folders…. as I would have assumed.

Write a comment

Sorry, you must be logged in to post a comment.