Qt Creator 未正确解析包含文件并显示大量错误
Qt Creator isn't parsing include files properly and displays lots of errors
Qt Creator 没有正确解析我项目中的包含文件,并在 IDE 中给出了很多错误,包括像 main.cpp:14:5: error: unknown type name 'QApplication'
这样的错误。但是,我的项目编译得很好。我已经厌倦了所有这些假定的错误,想知道是否有任何方法可以解决这个问题。
我的 .pro 文件如下所示:
QT += core gui widgets
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
klocktimer.cpp \
main.cpp \
klockmainwindow.cpp \
chronometer.cpp
TRANSLATIONS += \
klock_en_US.ts \
klock_es_MX.ts
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
HEADERS += \
klocktimer.h \
klockmainwindow.h \
chronometer.h
我几天前就有一种预感(我忘记了我是如何得到这种预感的)stddef.h
导致了这个问题。所以我在我的 main.cpp 中添加了 #include <stddef.h>
,Qt Creator 给出了错误:
/home/loren/code/klock/main.cpp:12: error: 'stddef.h' file not found
/usr/include/c++/9/ostream:42: to match this '{'
命名空间 std 中的“{”是 { 的开头。
Qt 论坛上有人告诉我转到帮助菜单 > 关于插件 > 禁用 ClangCodeModel 插件。这需要重新启动 Qt Creator,但它解决了我的问题。
Qt Creator 没有正确解析我项目中的包含文件,并在 IDE 中给出了很多错误,包括像 main.cpp:14:5: error: unknown type name 'QApplication'
这样的错误。但是,我的项目编译得很好。我已经厌倦了所有这些假定的错误,想知道是否有任何方法可以解决这个问题。
我的 .pro 文件如下所示:
QT += core gui widgets
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
klocktimer.cpp \
main.cpp \
klockmainwindow.cpp \
chronometer.cpp
TRANSLATIONS += \
klock_en_US.ts \
klock_es_MX.ts
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
HEADERS += \
klocktimer.h \
klockmainwindow.h \
chronometer.h
我几天前就有一种预感(我忘记了我是如何得到这种预感的)stddef.h
导致了这个问题。所以我在我的 main.cpp 中添加了 #include <stddef.h>
,Qt Creator 给出了错误:
/home/loren/code/klock/main.cpp:12: error: 'stddef.h' file not found
/usr/include/c++/9/ostream:42: to match this '{'
命名空间 std 中的“{”是 { 的开头。
Qt 论坛上有人告诉我转到帮助菜单 > 关于插件 > 禁用 ClangCodeModel 插件。这需要重新启动 Qt Creator,但它解决了我的问题。