Qt Visual Studio Add-in Frequently Asked Questions

ref: http://doc.qt.io/vs-addin/vs-addin-faq.html

Why is code completion not working?

1 You’re implementing a slot…

Visual Studio can only provide code completion as long as it understands the code. Unfortunately, it does not know how to handle the Qt keyword slots in the header file. This means that the respective function body is foreign to the code model and no code completion will be provided. You can workaround the problem be placing a ‘;’ after the colon of the slots keyword in the class declaration.

Note: Remember to remove the ‘;’ when exporting the project as the code might not compile with older Unix compilers.

1
2
3
4
5
6
7
8
9

class MyClass {
Q_OBJECT

public slots:;
void doSomething();

...
};

2 You are referencing objects from a .ui file

The Visual Studio code model parser only parses C++ sources, meaning that widgets or objects defined in .ui files will not be accessible. To workaround the problem, the Qt Visual Studio Add-in automatically generates C++ code from the .ui file by saving the file and running uic on it. This step is done everytime the project is built. If the code completion does not work, try to rebuild the project. It is possible that you have to wait some time, before code completion fully works after updating an .ui file. For more information, you can refer to the Modifying Project Properties section.

3 It still does not work

You should refresh the code model, Intellisense. This is done by opening the solution explorer, invoking the context menu of the project and activating the item Update Intellisense.