我已经将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似乎是错误的:
#include "../../qcustomplot.h"
由于您没有将QCustomPlot文件夹添加到中INCLUDEPATH
,因此需要包括以下文件:
#include "QCustomPlot/qcustomplot.h"
或者,您可以更改INCLUDEPATH
如下:
INCLUDEPATH += $$QT_PROJECT_DIR/QCustomPlot/
然后您可以包含标头,而没有难看的../../
相对引用,如下所示:
#include "qcustomplot.h"
根据经验,避免在源文件和标头文件本身中使用此类相对包含路径,因为结构可以随时更改,或者在不同的机器上可能有所不同,等。它可以由构建系统更好地解决,并包含路径。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句