没有这样的文件或目录#include <QDebug>

No such file or directory #include <QDebug>

为什么我收到错误:

我使用 Qt Creator。桌面版本 Qt 5.9.7

输出:::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::: ::

23:02:13: Uruchamianie "/usr/bin/make" 
g++ -c -pipe -g -std=gnu++11 -Wall -W -fPIC -DQT_QML_DEBUG -I../Kurs_STL_cpp0x -I. -I../../anaconda3/mkspecs/linux-g++ -o main.o ../Kurs_STL_cpp0x/main.cpp
../Kurs_STL_cpp0x/main.cpp:4:10: fatal error: Debug: No such file or directory
 #include <Debug>
          ^~~~~~~
compilation terminated.
Makefile:627: recipe for target 'main.o' failed
make: *** [main.o] Error 1
23:02:13: Proces "/usr/bin/make" zakończył się kodem wyjściowym 2.
Błąd budowania / instalowania projektu Kurs_STL_cpp0x (zestaw narzędzi: Desktop)
Podczas wykonywania kroku "Make"
23:02:13: Czas trwania: 00:00.

当您 select 一个 non-Qt 项目时,生成的 *.pro 文件被配置为禁用 Qt(并且您将无法包含 Qt 文件)。

在 *.pro 文件中,删除行 CONFIG -= qt 以启用 Qt。

之后,您可能需要将不同的 Qt 模块(widgets、quick 等)添加到环境变量 QT 中(默认情况下应启用模块 core 和 gui)。

例如,要使用 Qt Widgets 和 Qt Quick,您必须添加 QT += widgets quick

您还可以通过添加像 QT -= gui

这样的行来禁用无用的模块