qt: qt install framework使用问题;
qt提供了qt install framework用于程序打包,方便、快捷,并且可以对界面和功能进行自定义。
但是, 如果使用默认的打包配置,不进行安装页面功能自定义的话, 在修改安装路径时,在对程序进行卸载的时候,会将安装路径下的所有文件
全部删除。 那么,这就会导致一个问题: 如果用户修改了安装路径,没有新建文件夹用来安装,而是直接安装在了D:\目录下,在卸载的时候,会将
D:\下的所有文件全部清除掉。很操蛋的操作!
参考: https://stackoverflow.com/questions/46455360/workaround-for-qt-installer-framework-not-overwriting-existing-installation?r=SearchResults1、
这里采用自定义界面和功能的方式来解决该问题:
1、安装路径设置页面
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TargetWidget</class>
<widget class="QWidget" name="TargetWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>491</width>
<height>190</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>491</width>
<height>190</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="description">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="targetDirectory">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="targetChooser">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="warning">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>122</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
2、脚本
var targetDirectoryPage = null; function Component()
{
installer.gainAdminRights();
component.loaded.connect(this, this.installerLoaded);
} Component.prototype.createOperations = function()
{
// Add the desktop and start menu shortcuts.
component.createOperations();
component.addOperation("CreateShortcut",
"@TargetDir@/Atlas4500Tuner.exe",
"@DesktopDir@/Atlas4500 Tuner.lnk",
"workingDirectory=@TargetDir@"); component.addOperation("CreateShortcut",
"@TargetDir@/Atlas4500Tuner.exe",
"@StartMenuDir@/Atlas4500 Tuner.lnk",
"workingDirectory=@TargetDir@");
} Component.prototype.installerLoaded = function()
{
installer.setDefaultPageVisible(QInstaller.TargetDirectory, false);
installer.addWizardPage(component, "TargetWidget", QInstaller.TargetDirectory); targetDirectoryPage = gui.pageWidgetByObjectName("DynamicTargetWidget");
targetDirectoryPage.windowTitle = "Choose Installation Directory";
targetDirectoryPage.description.setText("Please select where the Atlas4500 Tuner will be installed:");
targetDirectoryPage.targetDirectory.textChanged.connect(this, this.targetDirectoryChanged);
targetDirectoryPage.targetDirectory.setText(installer.value("TargetDir"));
targetDirectoryPage.targetChooser.released.connect(this, this.targetChooserClicked); gui.pageById(QInstaller.ComponentSelection).entered.connect(this, this.componentSelectionPageEntered);
} Component.prototype.targetChooserClicked = function()
{
var dir = QFileDialog.getExistingDirectory("", targetDirectoryPage.targetDirectory.text);
targetDirectoryPage.targetDirectory.setText(dir);
} Component.prototype.targetDirectoryChanged = function()
{
var dir = targetDirectoryPage.targetDirectory.text;
if (installer.fileExists(dir) && installer.fileExists(dir + "/maintenancetool.exe")) {
targetDirectoryPage.warning.setText("<p style=\"color: red\">Existing installation detected and will be overwritten.</p>");
}
else if (installer.fileExists(dir)) {
targetDirectoryPage.warning.setText("<p style=\"color: red\">Installing in existing directory. It will be wiped on uninstallation.</p>");
}
else {
targetDirectoryPage.warning.setText("");
}
installer.setValue("TargetDir", dir);
} Component.prototype.componentSelectionPageEntered = function()
{
var dir = installer.value("TargetDir");
if (installer.fileExists(dir) && installer.fileExists(dir + "/maintenancetool.exe")) {
installer.execute(dir + "/maintenancetool.exe", "--script=" + dir + "/scripts/auto_uninstall.qs");
}
}
3、覆盖安装
var targetDirectoryPage = null; function Component()
{
installer.gainAdminRights();
component.loaded.connect(this, this.installerLoaded);
} Component.prototype.createOperations = function()
{
// Add the desktop and start menu shortcuts.
component.createOperations();
component.addOperation("CreateShortcut",
"@TargetDir@/Atlas4500Tuner.exe",
"@DesktopDir@/Atlas4500 Tuner.lnk",
"workingDirectory=@TargetDir@"); component.addOperation("CreateShortcut",
"@TargetDir@/Atlas4500Tuner.exe",
"@StartMenuDir@/Atlas4500 Tuner.lnk",
"workingDirectory=@TargetDir@");
} Component.prototype.installerLoaded = function()
{
installer.setDefaultPageVisible(QInstaller.TargetDirectory, false);
installer.addWizardPage(component, "TargetWidget", QInstaller.TargetDirectory); targetDirectoryPage = gui.pageWidgetByObjectName("DynamicTargetWidget");
targetDirectoryPage.windowTitle = "Choose Installation Directory";
targetDirectoryPage.description.setText("Please select where the Atlas4500 Tuner will be installed:");
targetDirectoryPage.targetDirectory.textChanged.connect(this, this.targetDirectoryChanged);
targetDirectoryPage.targetDirectory.setText(installer.value("TargetDir"));
targetDirectoryPage.targetChooser.released.connect(this, this.targetChooserClicked); gui.pageById(QInstaller.ComponentSelection).entered.connect(this, this.componentSelectionPageEntered);
} Component.prototype.targetChooserClicked = function()
{
var dir = QFileDialog.getExistingDirectory("", targetDirectoryPage.targetDirectory.text);
targetDirectoryPage.targetDirectory.setText(dir);
} Component.prototype.targetDirectoryChanged = function()
{
var dir = targetDirectoryPage.targetDirectory.text;
if (installer.fileExists(dir) && installer.fileExists(dir + "/maintenancetool.exe")) {
targetDirectoryPage.warning.setText("<p style=\"color: red\">Existing installation detected and will be overwritten.</p>");
}
else if (installer.fileExists(dir)) {
targetDirectoryPage.warning.setText("<p style=\"color: red\">Installing in existing directory. It will be wiped on uninstallation.</p>");
}
else {
targetDirectoryPage.warning.setText("");
}
installer.setValue("TargetDir", dir);
} Component.prototype.componentSelectionPageEntered = function()
{
var dir = installer.value("TargetDir");
if (installer.fileExists(dir) && installer.fileExists(dir + "/maintenancetool.exe")) {
installer.execute(dir + "/maintenancetool.exe", "--script=" + dir + "/scripts/auto_uninstall.qs");
}
}
4、翻译
在脚本中的文字,可以通过qsTr函数进行标记;
利用
lupdate installscript.qs targetWidget.ui -ts [语言].ts
生成ts文件,然后使用linguist进行翻译生成qm文件;
qt: qt install framework使用问题;的更多相关文章
- Qt's Undo Framework
Overview of Qt's Undo Framework Introduction Qt's Undo Framework is an implementation of the Command ...
- Qt... configure: error: Qt (>= Qt 2.2.2) (headers…
转载:http://blog.chinaunix.net/uid-23733724-id-290980.html 昨天开始在自己的fedora12下装qt~ 但是按照教程在/opt/Embed ...
- Qt, QT/E, Qtopia 的区别
转自Qt, QT/E, Qtopia 的区别 Qt泛指Qt的所有桌面版本,比如Qt/X11,Qt Windows,Qt Mac等.由于Qt最早是在Linux中随着KDE流行开来的,因此通常很多人说的Q ...
- QT QT creator QTsdk的区别
Qt是一个跨平台的C++图形用户界面应用程序框架.它提供给应用程序开发者建立艺术级的图形用户界面所需的所用功能.Qt是完全面向对象的,很容易扩展,并且允许真正地组件编程. QT Creator 跨平台 ...
- QT,QT SDK, QT Creator 区别
Qt是一个跨平台的C++图形用户界面应用程序框架.(不仅仅是C++,还包括QML,Qquick,html5)它提供给应用程序开发者建立艺术级的图形用户界面所需的所用功能.Qt是完全面向对象的,很容易扩 ...
- qt Graphics View Framework(非重点)
Graphics View 提供了一种接口,用于管理大量自定义的 2D 图形元素,并与之进行交互:还提供了用于将这些元素进行可视化显示的观察组件,并支持缩放和旋转. 说明;Graphics View ...
- 【QT】qt python install pip
https://pip.pypa.io/en/stable/installing/ http://www.runoob.com/w3cnote/python-pip-install-usage.htm ...
- [QT]QT概述
QT概述 基于C++的GUI开发框架,跨平台.Qt 是一个用于桌面系统和嵌入式开发的跨平台应用程序框架. QT是挪威TROLLTECH公司开发的跨平台C++工具,在UNIX下非常出名:他的宗旨是“一次 ...
- Qt.Qt新安装之后出现Error while building/deploying (kit: Desktop Qt 5.7.0 GCC 64bit) When executing step "Make”
出问题的环境: 操作系统: Ubuntu18.04 安装包: qt-opensource-linux-x64-5.8.0.run 现象: 新建一个Hello World项目, 试着运行, 出现以下提示 ...
随机推荐
- delegate--委托
delegate--委托 (可以把委托看成用来执行方法的一个东西) eg: namespace delegateTest{ delegate double MathsOp(double x); cla ...
- Nginx+Tomcat 负载均衡集群
案例分析 通常情况下,一台Tomcat站点由于可能出现单点故障及无法应对多客户复杂多样性的请求等问题,不能单独应用于生产环境下,所以我们需要一套更可靠的解决方案来完善Web站点架构. Nginx是一款 ...
- HTML元素类别及转换
位置特性分类元素分为三类:块级元素,行内元素,行级块元素 1.块级元素(block) 特点: (1)可以设置宽高.内.外边距: (2)独占一行(即前后均有换行 ...
- BZOJ4205卡牌配对——最大流+建图优化
题目描述 现在有一种卡牌游戏,每张卡牌上有三个属性值:A,B,C.把卡牌分为X,Y两类,分别有n1,n2张. 两张卡牌能够配对,当且仅当,存在至多一项属性值使得两张卡牌该项属性值互质,且两张卡牌类别不 ...
- 微信小程序——创建自己的第一个小程序【一】
注册 微信小程序注册 https://mp.weixin.qq.com/wxopen/waregister?action=step1 填写账号信息 作为登录帐号,请填写未被微信公众平台注册,未被 ...
- [CEOI2007] 树的匹配Treasury
类型:树形 DP 传送门:>Here< 题意:给一棵树,你可以匹配有边相连的两个点,问你这棵树的最大匹配是多少,并且计算出有多少种最大匹配. 解题思路 首先树形Dp是很明显的,$f[i][ ...
- 【GZOI2015】石子游戏 博弈论 SG函数
题目大意 有\(n\)堆石子,两个人可以轮流取石子.每次可以选择一堆石子,做出下列的其中一点操作: 1.移去整堆石子 2.设石子堆中有\(x\)个石子,取出\(y\)堆石子,其中\(1\leq y&l ...
- OpenDCIM-19.01操作手册
OpenDCIM-19.01操作手册 1. 界面标签解析 1.1 用户管理 用户管理 部门管理 用户管理被存在数据表fac_User中,包含以下字段: UserID:是管理员还是用户 Name:报表 ...
- 【洛谷2252&HDU1527】取石子游戏(博弈论)
题面 HDU1527 取石子游戏 洛谷2252 取石子游戏 题解 裸的威佐夫博弈 #include<iostream> #include<cmath> using namesp ...
- 763. Partition Labels
我一开始看数据范围很小,没怎么想就直接暴力了. 暴力的思路是: 对于每一段S的前缀,这个前缀中的每一个字母都不应该在前缀的补集中出现,所以直接循环i:0 to S.length然后对于每一次循环,再循 ...