Qt自动生成的表单提供了错误的源代码文件路径
Qt auto generated form provides wrong path to source code files
我已经将qcustomplot.h/.c文件添加到我的Qt项目中。它们位于:"QT_PROJECT_DIR/QCustomPlot/"。
每次我在Qt Creator中使用设计器并构建时,都会在ui_mainwindow.h中收到此错误:
error: ../../qcustomplot.h: No such file or directory
#include "../../qcustomplot.h"
这当然是正确的,因为它位于:"QT_PROJECT_DIR/QCustomPlot/"
如何更改Qt Designer自动生成此路径的方式?
如果有帮助,这是我的 .pro:
#-------------------------------------------------
#
# Project created by QtCreator 2014-01-12T00:44:44
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets widgets opengl printsupport
TARGET = Test
TEMPLATE = app
SOURCES += main.cpp
mainwindow.cpp
QCustomPlot/qcustomplot.cpp
HEADERS += mainwindow.h
QCustomPlot/qcustomplot.h
FORMS += mainwindow.ui
CONFIG += mobility
MOBILITY =
您的包含似乎是错误的:
#include "../../qcustomplot.h"
由于您没有将 QCustomPlot 文件夹添加到INCLUDEPATH
中,因此您需要包含该文件,如下所示:
#include "QCustomPlot/qcustomplot.h"
或者,您可以按如下方式更改INCLUDEPATH
:
INCLUDEPATH += $$QT_PROJECT_DIR/QCustomPlot/
然后,您可以包含没有丑陋../../
相对引用的标题,如下所示:
#include "qcustomplot.h"
根据经验,避免在源文件和头文件本身中使用此类相对包含路径,因为结构可以随时更改,或者在不同的计算机上可能不同,等等。它最好由构建系统解决并包含路径。
我遇到了同样的问题并解决了它。
它是由 xxx.ui
中 qcustomplot 对象的路径引起的。
步骤1:打开包含qcustomplot项目的***.ui
文件。
步骤2:右键单击qcustomplot项目
步骤3:双击QCustomPlot的路径,然后将其更改为QCustomPlot/qcustomplot.cpp
from ../../customplot
.
最后,ui_***.h
的标头可以自动包含QCustomPlot/qcustomplot.cpp
,而不是../../qcustomplot.h
。
我的母语不是英语。如果您在我的回复中发现语法错误,请通知我。让我纠正一下。
相关文章:
- C++出现控制台错误.我无法识别源代码的问题
- 以下 OpenCV 源代码中是否存在错误?(#ifdef 没有 #else)
- 节点C++源代码编译错误
- 使用 bazel 从源代码构建张量流服务遇到错误:C++规则'@org_tensorflow//…'编译失败(出口 4)
- Qt 5 中源代码外构建的链接器错误
- Bullet Physics源代码未在X86中构建 - Visual Studio 2017中错误的预处理器指令
- 从MACOS上的源代码构建QT时错误
- GRPC C++从源代码构建致命错误
- 有没有办法使用 Clang 减小编译器错误测试用例的预处理源代码的大小
- 从源代码构建 MySQL 连接器/C++(找不到 Boost 库错误)
- 我正在为我的C 项目添加Offocial SQLite源代码,并获得链接器错误
- Qt自动生成的表单提供了错误的源代码文件路径
- 源代码生成的gcc链接错误
- 编译比特币源代码时出现SOCKET错误
- SDL 项目的调试错误"没有可用于 main() 的源代码"
- 如何在没有源代码的tcp服务器应用程序中查找错误
- 有关 -fPIC 的链接错误,即使所有源代码都使用 -fPIC 编译
- 在 Mac 10.9 上从 Android 源代码构建 aapt 小牛队在 10.8 山狮上出现段错误或给出"Illegal Instruction 4"
- 如何将 Open GL 驱动程序中的分段错误追溯到我的源代码
- 源代码在c ++中调用错误的模板类函数,如何修复