如何在基于 Qt Widget 的应用程序中使用 DEPLOYMENTFOLDERS 指令 [英] How to use DEPLOYMENTFOLDERS directive in Qt Widget based application

查看:47
本文介绍了如何在基于 Qt Widget 的应用程序中使用 DEPLOYMENTFOLDERS 指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 Qt Creator 创建 Qt Quick/QML 项目时,它会将 DEPLOYMENTFOLDERS 添加到 .pro 文件中.我可以使用此指令在构建(编译)应用程序时将一些文件夹/文件复制到构建目录.

When I use the Qt Creator to create a Qt Quick / QML project it adds DEPLOYMENTFOLDERS to the .pro file. I can use this directive to get some folders/files copied to the build directory upon building (compilation) of the application.

如何在基于 Qt Widget 的简单应用程序中使用它?

How can I use this in a simple Qt Widget based application?

Qt Creator 不会为简单的 Qt 项目添加它,当我手动添加时,它不起作用.

Qt Creator doesn't add it for a simple Qt project and when I manually do it, it's not working.

这是我的项目文件:

folder_01.source = sounds
#folder_01.target =
DEPLOYMENTFOLDERS += folder_01

QT += core gui widgets
TARGET = myApp
TEMPLATE = app
SOURCES += main.cpp

我试过 "/sounds" 和 "sounds/*" 并且这样想.但没有任何作用.我在这里错过了什么?

I tried "/sounds" and "sounds/*" and thinks like that. But nothing works. What am I missing here?

推荐答案

我正在研究这个并偶然发现了这个悬而未决的问题.

I was researching this and stumbled on this unanswered question.

基本上我确实提倡使用资源系统,但是当您进行快速 UI 开发 (qml) 时,等待资源文件编译可能会很烦人,所以我想简单地复制这些文件.

Basically I do advocate using the resource system but when you're doing rapid UI development (qml) waiting for the Resource file to compile can be an irritation so I wanted to simply copy this files over.

这里令人困惑的是源/目标的含义略有不同.描述它的最好方法是 copy this ->这个根而不是copy this ->这里

What is confusing here is the source/target mean slightly different things. The best way to describe it is copy this -> this root as opposed to copy this -> here

我的构建只是希望我的资源在路径上是原始的",所以我正在复制 folder->/这是我拥有的项目文件的示例:

My build simply wants my resources "raw" on the path so I am copying folder->/ Here's an example of the project file I have:

folder_qml.source = qml
folder_qml.target = /
folder_js.source = js
folder_js.target = /
folder_img.source = img
folder_img.target = /
DEPLOYMENTFOLDERS += folder_qml folder_js folder_img

构建时可以验证输出:

10:41:57: Starting: "C:\Qt\Qt5.2.1\Tools\mingw48_32\bin\mingw32-make.exe" 
C:/Qt/Qt5.2.1/Tools/mingw48_32/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'C:/Development/Subversion/MyBuild-Desktop_Qt_5_2_1_MinGW_32bit-Debug'
Copying application data... 
60 File(s) copied
12 File(s) copied
6 File(s) copied
mingw32-make[1]: Leaving directory 'C:/Development/Subversion/MyBuild-Desktop_Qt_5_2_1_MinGW_32bit-Debug'
Copying application data... 
60 File(s) copied
12 File(s) copied
6 File(s) copied
10:41:58: The process "C:\Qt\Qt5.2.1\Tools\mingw48_32\bin\mingw32-make.exe" exited normally.

生成的构建看起来像:

/Build dir/
  + release
  + debug
  + qml
  + js
  + img
  Makefile.Release
  Makefile.Debug
  Makefile

我希望这有助于回答您的问题.我没有找到任何关于它的文档,所以我只是玩它直到它工作.(对于测试的模拟数据非常有帮助).

I hope this helps answer your question. I didn't find any documentation on it so I just played with it until it worked. (It is very helpful with mock-data for tests).

这篇关于如何在基于 Qt Widget 的应用程序中使用 DEPLOYMENTFOLDERS 指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆