找不到包含文件 QtCore?

发布于 2024-10-04 10:23:45 字数 143 浏览 3 评论 0原文

我正在用 C++ 编写一个多线程程序,并计划使用 QThread。问题是当我尝试 #include... 我收到错误... 找不到包含文件 QtCore。

给出了什么?

I'm writing a multithreaded program in C++, and plan to use QThread. Problem is when I try to #include <QtCore>... I get an error... Cannot find include file QtCore.

What gives?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

往昔成烟 2024-10-11 10:23:45

您可能有指向 Qt 根包含目录的包含目录,因此请尝试:

#include <QtCore/QtCore>

...或者...您的编译器命令行中没有引用 Qt 的包含目录。

You probably have the include directories point to root include directory of Qt, so try:

#include <QtCore/QtCore>

... or... you don't have the include directories refering to Qt in your compiler command line.

丑疤怪 2024-10-11 10:23:45

这个问题有一个有效的答案对我来说,当 Visual Studio 无法识别我的 Qt 项目中的 #include 语句时。在我的情况下,编译和构建工作正常,IDE 将指示 #include 行不正确,并显示消息“找不到包含文件 XXX”。

上面链接的问题指向有关 intellisense 和 QT 的诺基亚页面,该页面表明Visual Studio 应从 QT 二进制发行版附带的“Qt x.xx for Desktop (MSVC 20xx)”命令提示符启动。从 QT 命令提示符启动 Visual Studio 后,我的问题就消失了。

This SO question has an answer which worked for me when Visual Studio did not recognize #include statements in my Qt project. While compiling and building worked in my case, the IDE would indicate that the #include line was incorrect and show a message 'Cannot find include file XXX'.

The question linked to above points to a nokia page about intellisense and QT which indicates that Visual Studio should be launched from the "Qt x.xx for Desktop (MSVC 20xx)" command prompt included with the binary distribution of QT. After launching Visual Studio from the QT command prompt my problem went away.

离鸿 2024-10-11 10:23:45

听起来您的 .pro 文件配置不正确。

您的错误来源是编译器,它提供了错误的包含目录 - 这就是找不到 QtCore 的原因。

如果您不使用 qmake(而是使用普通的 Makefile)、CMake 并且配置不正确等等,就会发生这种情况。说实话,这可能有很多原因。

您可以发布您的 .pro 文件或 Makefile 的内容吗?请告诉我们更多关于如何您实际上开始编译的信息?

Sounds like your .pro file is configured incorrectly.

Your error's source is the compiler, which is fed the wrong include directories - this is why QtCore can't be found.

This can happen if you don't use qmake (and a plain Makefile instead), CMake and have it configured incorrectly, etc., etc. To be honest, it can have a lot of reasons.

Can you post the contents of your .pro-file or Makefile? And tell us a bit more about more about how you actually start compilation?

柳絮泡泡 2024-10-11 10:23:45

在我发现我必须在 qt Creator 上安装 Windows 10 sdk 配置调试器后,有一个类似的问题正在搜索和重新安装,最重要的是当我启动 qtwidget 项目时,我在开始时使用了 windows .Net Framework,然后是 qt 小部件

Had a similar Problem was searching and reinstalling after i found out that i had to install the windows 10 sdk configure debugger on qt creator most important when i started the qtwidget project i used at the beginning the windows .Net Framework and then the qt widget

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文