因此,我阅读了一些有关如何执行此操作的帖子和文章,其中一种选择是:
#include "../file/file.h"
但是当我使用这种方法时,它仍然找不到文件。另一种方法是将项目的根目录添加到包含路径。
所以这里是一个示例目录:
main_dir
- dir2
-dir3
-header.h
-dir4
-dir 5
-source.cpp
因此,如果我试图从 source.cpp 中包含 header.h,我该怎么做?
我的简历
#-------------------------------------------------
#
# Project created by QtCreator 2015-02-17T12:52:00
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = project1
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
dir4/dir 5/source.cpp \
HEADERS += mainwindow.h \
dir2/dir3/header.h
FORMS += mainwindow.ui