简体   繁体   中英

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?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM