简体   繁体   English

Codelite 5.1找不到<QString>

[英]codelite 5.1 cannot find <QString>

Using CodeLite 5.1 on Ubuntu 12.10: 在Ubuntu 12.10上使用CodeLite 5.1:

Created a minimal QTGui app. 创建了一个最小的QTGui应用程序。 Built and ran fine. 建成并运行良好。

#include <QApplication> 
#include <QButton> 

were inserted by the wizard in the main.cpp file - no problem. 由向导插入到main.cpp文件中-没问题。 I added: 我补充说:

#include <QString> 

as per QT docs, and pre-processer tells me it can't find QString. 根据QT文档,预处理器告诉我找不到QString。 I checked the include setting for the projects - 我检查了项目的包含设置-

../qt4 

and

../qt4/qt4GUI 

are there correctly. 正确在那里。 I tried: 我试过了:

#include <qt4/QString>

with different case permutations - all no go. 具有不同的大小写排列-都不行。

What's wrong? 怎么了? (Posting this also on CodeLite forum). (还将其发布在CodeLite论坛上)。

While QApplication and QButton are part of the Qt GUI module, QString is part of the Qt Core module. QApplicationQButton是Qt GUI模块的一部分,而QString是Qt Core模块的一部分。 GUI depends on Core, so the Core library is already linked, that's not the problem. GUI取决于Core,因此Core库已经链接了,这不是问题。

The problem seems that your include path only includes the Qt top level as well as the GUI sub-directory. 问题似乎在于您的包含路径仅包括Qt顶级以及GUI子目录。 Qt's header files are structured in modules, one directory for each module. Qt的头文件在模块中构造,每个模块一个目录。 This means that the <QApplication> and <QButton> headers are in ../qt4/qt4GUI and can thus be found by the compiler. 这意味着<QApplication><QButton>标头位于../qt4/qt4GUI ,因此可以由编译器找到。

However, QString is placed in ../qt4/qt4Core (1) and thus has either be included as #include <QtCore/QString> (2) which will look in the correct module sub-directory, or by adding the sub-directory to your include paths in the project configuration (recommended), so #include <QString> works too. 但是, QString放在../qt4/qt4Core )中 ,因此已包含在#include <QtCore/QString> (2)中 ,它将在正确的模块子目录中查找,或者通过添加子目录到项目配置中的包含路径(推荐),因此#include <QString>也可以。


(1) I think this should be ../qt4/QtCore , and for Qt GUI ../qt4/QtGui , but you wrote something different in the question... (1)我认为这应该是../qt4/QtCore ,对于Qt GUI是../qt4/QtGui ,但是您在问题中写了一些不同的东西...

(2) Iternally in Qt, classes of other modules are included like this, ie relative to the Qt top level include path, so if you include a class which uses QString ( QApplication being one example), it's working without adding another include. (2)在Qt的内部,其他模块的类是这样包含的,即相对于Qt顶级包含路径,因此,如果包含一个使用QString的类( QApplication是一个示例),则无需添加另一个include就可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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