2012. július 18., szerda

Fix Qt code completion/parsing in Eclipse

Some Qt magic macros cause problems for the C++ code parser in Eclipse and it shows "Syntax error" on some lines in the editor. Some problematic macros: e.g Q_OBJECT, Q_SIGNALS, Q_SLOTS, SLOT(), SIGNAL(). Other problems are skipped classes in the Qt includes because of the export macros before the class names: e.g Q_NETWORK_EXPORT breaks QUdpSocket, QTcpSocket etc.

Solution:
- Add the following preprocessor symbols in Project/Properties/C/C++ Include Paths and Symbols with "Add Preprocessor Symbol..." button one by one:

Q_SLOTS=
Q_OBJECT=
Q_SIGNALS=public
SIGNAL(a)="sallala"
SLOT(a)="sallala"
Q_CORE_EXPORT=
Q_NETWORK_EXPORT=
Q_DISABLE_COPY(a)=public:

Voilá, works. This preprocessor symbols affect only the code parser and the syntax checks in the C++ editor.

PS: If somebody knows about additional preprocessor symbols what is worth to add, please write in the comments.

Nincsenek megjegyzések: