QML目录尚未发布

时间:2017-03-08 15:29:29

标签: qt qml qt-creator qmake

我有一个像这样的项目结构:

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.prorelease ,模式?

1 个答案:

答案 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 = ...
}