eclipse
eclipse

Reputation: 765

How to enable qt4 code completion in eclipse?

I develop app with some elements of Qt. I use cmake as build system and Eclipse only as editor and debugger. Everything comiles fine (thanks to CMake), however I can't force IDE to complete my Qt code.

Many times someone asked about it and the solution was to add include path. I did it of course, but

#include <QtSql>

is different, because there is no such file in include dir. It probably would work if I include all necassary files by hand. Is there any way to make Eclipse understand that "QtSql" means all classes from this module?

Upvotes: 1

Views: 598

Answers (2)

Andreas Fester
Andreas Fester

Reputation: 36630

From your question, I assume that you already have set up other Qt modules like QtCore or QtGui in Eclipse, if not please see this posting: https://stackoverflow.com/a/12670991/1611055

To also use the QSql submodule (without the eclipse Qt Plugin which is, IMHO, not maintained anymore) you need to add the following settings in "Project Properties => C/C++ General => Paths and Symbols":

On the "Includes" tab, for the GNU C++ language, add the following include paths:

/usr/include/qt4/QtSql

On the "Symbols" tab, for the GNU C++ language, add the following symbols with a value of "1":

QT_SQL_LIB

With these settings, the Eclipse C++ indexer also knows the QtSql classes.

Upvotes: 0

jviotti
jviotti

Reputation: 18929

Install qt4 eclipse integration package. You can find instructions here

As the webpage says, the module package should live inside eclipse/plugins, untar the package and start eclipse just one time from the command-line:

eclipse -clean

Upvotes: 3

Related Questions