如何使用qt安装程序框架更改安装程序路径和添加子文件夹。
默认输出:
C:\Program Files (x86)\Subfolder
我想要路径到示例输出。
输出示例:
D:\Subfolder
C:\Desktop\Subfolder
C:\Documents\Subfolder
发布于 2018-09-18 23:48:52
我知道这是旧的,但可能是有用的人。
我更改了一个名为dynamicpage的Qt安装程序框架示例(查看QtIfw示例目录),其中的目标目录是从一个名为targetwidgetui的自定义小部件中选择的。为了避免用户直接在行编辑中编写代码,我在文件config/config erscript.qs中添加了以下代码:
Controller.prototype.TargetDirectoryPageCallback = function()
{
currentPage.TargetDirectoryLineEdit.enabled = false;
}
我还在config.xml中添加了@ApplicationsDir@/MyAppFolder,因此这是默认的安装路径。
当用户更改目标文件夹时,我会获取路径并附加"/MyAppFolder“。为此,我在文件installscript.qs中更改了动态页面示例中的一个函数。下面是我的函数现在的样子:
Component.prototype.chooseTarget = function () {
var widget = gui.pageWidgetByObjectName("DynamicTargetWidget");
if (widget != null) {
var newTarget = QFileDialog.getExistingDirectory("Choose your target directory.", widget
.targetDirectory.text);
if (newTarget != "")
{
newTarget += "/MyAppFolder"; // The same subfolder of TargetDir in config.xml
widget.targetDirectory.text = Dir.toNativeSparator(newTarget);
}
}
}
使用此选项,您将始终将您的文件夹附加到安装路径。
发布于 2015-11-16 21:22:24
在config.xml
文件中,您可以添加
<TargetDir>*YOUR_PATH*/subfolder</TargetDir>
若要安装到自定义目录,请执行以下操作。
来自Qt Installer Framework documentation
TargetDir
安装的默认目标目录。在Linux上,这通常是用户的主目录。
注意,您可以使用像@ApplicationsDir@
或@DesktopDir@
这样的预定义变量作为stated here。
https://stackoverflow.com/questions/33730457
复制相似问题