我有一個我用 VS2017 撰寫的專案,它有很多靜態庫,我已經到了想要開始改進 gui 的地步。為了確保我可以使用 Qt,我使用https://www.toptal.com/qt/vital-guide-qmake中的提示制作了一個測驗子目錄程式,https://wiki.qt.io/SUBDIRS_-_handling_dependencies示例, https://github.com/rainbyte/example-qmake-subdirs和https://github.com/219-design/qt-qml-project-template-with-ci/tree/6af6488d74e1dc97a8cef545080074055a696e9a專案以及幾個關于SO的類似問題。
這包括一個名為“project”的子目錄專案,其中包含 2 個子專案“app”和“library”。這些都是使用 New Subproject 向導創建的簡單 QtApplications,除了 main.cpp 之外的所有檔案都從“app”中洗掉,除了 main.cpp 之外的所有檔案都留在了“library”中,重點是確保 mainwindow.h 在“庫”是從“app”中的 main.cpp 參考的。盡管嘗試了我能找到的每個示例,但我仍然收到“'mainwindow.h' file not found”錯誤。
根據我能找到的所有示例,您只需要在向導生成的 .pro 檔案中添加幾行 (#),然后在“庫”專案中添加一個額外的 .pri 檔案;
目錄結構;
project/
project.pro
app/
app.pro
main.ccp
library/
library.pro
mainwindow.h
mainwindow.ccp
mainwindow.ui
library.pri
專案.pro;
TEMPLATE = subdirs
TARGET = project ##
SUBDIRS = \
app \
library
app.depends = library ##
應用程式.pro;
TEMPLATE = app ##
TARGET = app ##
QT = core gui
greaterThan(QT_MAJOR_VERSION, 4): QT = widgets
CONFIG = c 11
SOURCES = \
main.cpp
include(../library/library.pri) ##
圖書館.pro;
TEMPLATE = lib ##
TARGET = library ##
QT = core gui
greaterThan(QT_MAJOR_VERSION, 4): QT = widgets
CONFIG = c 11
CONFIG = shared ##
CONFIG = lib_bundle ##
SOURCES = \
mainwindow.cpp
HEADERS = \
mainwindow.h
FORMS = \
mainwindow.ui
DISTFILES = \
library.pri ##
and the added library.pri file;
LIBTARGET = library
BASEDIR = $${PWD}
INCLUDEPATH *= $${BASEDIR}/include
LIBS = -L$${DESTDIR} -llibrary
I know this has been asked many times already but I can find no definitive solution, or rather no-one seems to have bothered to post their working solution. I'd really appreciate any help with this, I'd love to be able to use Qt and escape the purgatory of win32 ui creation.
uj5u.com熱心網友回復:
你有這個:
INCLUDEPATH *= $${BASEDIR}/include
include但是您似乎沒有在任何地方命名的目錄。所以可能/include從上面洗掉部分。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/448157.html
標籤:c qt subdirectory
