Unresolved inclusion of Qt in Eclipse

2020-07-17 15:02发布

问题:

Eclipse fails to locate Qt includes. Likewise, it fails to provide auto-complete functionality for Qt classes.

I did Project -> Properties -> Paths and Symbols -> Includes -> Add to the include directories of Qt in /usr/include/qt4/. This caused Eclipse to recognize certain certain classes such as QString; however, there is no auto-complete.

I have scoured the web to no avail. How do I make Eclipse index Qt into my project?

Edit: 12/20/12

I have solved my own problem. It appears order of the includes matter. I put

'usr/include/qt4'
'usr/include/qt4/Qt'
'usr/include/qt4/QtCore'
'usr/include/qt4/QtGui'

into Project Properties -> C++ General -> Paths & Symbols. I rebuilt and the auto-complete worked.

回答1:

You need to add several include directories, those listed by e.g. the command

 pkg-config --cflags QtGui QtXml QtSvg QtDBus

(and others Qt packages).