Vla*_*lad 9 installation installer qt qif qt-installer
我已经能够为我的软件创建一个安装.但是,我无法弄清楚如何创建另一个可以更新以前安装的安装程序.
我已经更新了组件版本,软件版本和发布日期,但每当我在预装软件的文件夹上运行第二次安装时 - 我都会得到 The folder you selected already exists and contains an installation. Chose different target for installation.
有关如何使用Qt安装程序框架更新现有安装的任何提示都将非常受欢迎!
我也面临同样的问题。所以我下载了最新的快照并研究了示例。其中一个特别有帮助:dynamicpage
当用户选择现有位置时,我没有成功地向用户显示弹出警告,因此我找到了解决方法:相反,在所选目录下显示红色标签。
这并不是真正逐个更新组件的解决方案,但您将能够继续安装过程。
首先,我们需要替换默认页面“TargetDirectory”。
installerscript.qs,您需要添加以下内容:// Constructor
function Component()
{
component.loaded.connect(this, Component.prototype.installerLoaded);
installer.setDefaultPageVisible(QInstaller.TargetDirectory, false);
}
// Utility function like QString QDir::toNativeSeparators(const QString & pathName) [static]
var Dir = new function () {
this.toNativeSparator = function (path) {
if (installer.value("os") == "win")
return path.replace(/\//g, '\\');
return path;
}
};
// Called as soon as the component was loaded
Component.prototype.installerLoaded = function()
{
if (installer.addWizardPage(component, "TargetWidget", QInstaller.TargetDirectory)) {
var widget = gui.pageWidgetByObjectName("DynamicTargetWidget");
if (widget != null) {
widget.targetDirectory.textChanged.connect(this, Component.prototype.targetChanged);
widget.targetChooser.clicked.connect(this, Component.prototype.chooseTarget);
widget.windowTitle = "Installation Folder";
widget.targetDirectory.text = Dir.toNativeSparator(installer.value("TargetDir"));
}
}
}
// Callback when one is clicking on the button to select where to install your application
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 != "") {
widget.targetDirectory.text = Dir.toNativeSparator(newTarget);
}
}
}
Component.prototype.targetChanged = function (text) {
var widget = gui.pageWidgetByObjectName("DynamicTargetWidget");
if (widget != null) {
if (text != "") {
widget.complete = true;
installer.setValue("TargetDir", text);
if (installer.fileExists(text + "/components.xml")) {
var warning = "<font color='red'>" + qsTr("A previous installation exists in this folder. If you wish to continue, everything will be overwritten.") + "</font>";
widget.labelOverwrite.text = warning;
} else {
widget.labelOverwrite.text = "";
}
return;
}
widget.complete = false;
}
}
Run Code Online (Sandbox Code Playgroud)
这实际上不是真正的 .ui 文件,仅用于解释目的。在此文件的末尾,我添加了一个名为 的空 QLabel labelOverwrite。回调中文本填充为红色消息targetChanged。
<widget class="QWidget" name="TargetWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Please specify the folder where Miam-Player will be installed.</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="targetDirectory"/>
</item>
<item>
<widget class="QToolButton" name="targetChooser"/>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="labelOverwrite"/>
</item>
</layout>
</widget>
Run Code Online (Sandbox Code Playgroud)
<?xml version="1.0" encoding="UTF-8"?>
<Package>
<DisplayName>Miam-Player</DisplayName>
<Description>Miam-Player is the main program. It is required and cannot be unselected.</Description>
<Name>org.miamplayer.core</Name>
<Script>installscript.qs</Script>
...
<UserInterfaces>
<UserInterface>targetwidget.ui</UserInterface>
</UserInterfaces>
</Package>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3972 次 |
| 最近记录: |