我有一个像这样的项目结构:
project
-project.pro (subdirs)
|-app
| |-app.pro (app)
| |-QML
| |-CPP
| |-ICONS
|
|-lib
|-lib.pro (subdirs, copied from qtvirtualkeyboard/src)
|-config.pri (copied from qtvirtualkeyboard/src)
|-virtualkeyboard
|-...
lib
- dir等于qtvirtualkeyboard/src只有dir,项目从 src 重命名为 lib 。
当我点击 QtCreator 中的运行时,现在一切正常
但是,由于我希望使用windeployqt
进行部署,问题是QML
- 目录不会复制到release
- 目录。
当我部署它时(make install
后跟windeployqt
),我得到了文件结构:
project
|-.moc
|-.obj
|-.pch
|-.rcc
|-debug
|-QML <-- This should not be here, but a subdir of release
|-release
|-app.exe
|-...otherstuff
我认为可能(我的错)是.qmake.conf
的错误,我不理解并从qtvirtualkeyboard
.qmake.conf:
load(qt_build_config)
MODULE_VERSION = 5.8.1
.qmake.stash:
QMAKE_DEFAULT_INCDIRS = \
D:/Qt/Qt5.7.0/Tools/mingw530_32/lib/gcc/i686-w64-mingw32/5.3.0/include \
D:/Qt/Qt5.7.0/Tools/mingw530_32/lib/gcc/i686-w64-mingw32/5.3.0/include-fixed \
D:/Qt/Qt5.7.0/Tools/mingw530_32/i686-w64-mingw32/include \
D:/Qt/Qt5.7.0/Tools/mingw530_32/i686-w64-mingw32/include/c++ \
D:/Qt/Qt5.7.0/Tools/mingw530_32/i686-w64-mingw32/include/c++/i686-w64-mingw32 \
D:/Qt/Qt5.7.0/Tools/mingw530_32/i686-w64-mingw32/include/c++/backward
QMAKE_DEFAULT_LIBDIRS = \
D:/Qt/Qt5.7.0/Tools/mingw530_32/lib/gcc/i686-w64-mingw32/5.3.0 \
D:/Qt/Qt5.7.0/Tools/mingw530_32/lib/gcc \
D:/Qt/Qt5.7.0/Tools/mingw530_32/i686-w64-mingw32/lib \
D:/Qt/Qt5.7.0/Tools/mingw530_32/lib
或者在项目文件中,lib.pro
中的一个直接从存储库中复制,并且app.pro
本身运行正常,然后我将其作为{{的子项目重新定位1}}。
(编辑)app.pro
project.pro
我如何解决这个问题,besids添加自定义部署步骤来复制QML-dir?根据 @KevinKrammer 的回答,我得出结论问题在于:TEMPLATE = app
QT += qml quick
CONFIG += c++11 \
disable-desktop
SOURCES += main.cpp \
...
RESOURCES += \
ICONS\ICONS.qrc
QML_IMPORT_PATH =
include(deployment.pri)
DISTFILES += \
QML/...
...
HEADERS += \
CPP/...
...
qmlsrc.files = QML/*
qmlsrc.path = $$OUT_PWD/QML
INSTALLS += qmlsrc
。 qmlsrc.path = $$OUT_PWD/QML
包含生成Makefile的路径。这是正确的,如果我只运行OUT_PWD
,但是当我运行app.pro
时,它应该等同于project.pro
所以$$OUT_PWD/[debug,relase,...]/QML
是否有办法以某种方式一般地编写,它在两种情况下都有效:当我运行$$PATH_TO_THE_EXE/QML
和运行project.pro
时,app.pro
和release
,模式?
答案 0 :(得分:2)
您可以指定文件,甚至使用通配符模式,作为additional安装目标,
qmlfiles.files = QML/*
qmlfiles.path = $$OUT_PWD/QML
INSTALLS += qmlfiles
调试/发布差异可以通过两种方式处理
debug:qmlfiles.path = $$OUT_PWD/debug/QML
release:qmlfiles.path = $$OUT_PWD/release/QML
或
CONFIG(debug, debug|release) {
qmlfiles.path = ...
} else {
qmlfiles.path = ...
}