我正在使用
QtInstallerFramework
,并且我尝试在 卸载应用程序时添加自定义页面。
我有
custompage.ui
文件(简单文本),我将其添加到我的 package.xml
:
<UserInterfaces>
<UserInterface>custompage.ui</UserInterface>
</UserInterfaces>
这就是我在我的
componentscript.js
中使用它的方式:
Component.prototype.componentLoaded = function ()
{
installer.addWizardPage(component, "CustomPage", QInstaller.ReadyForInstallation)
}
问题是只有当我安装应用程序时才会显示该页面。当我卸载它时,自定义页面不显示。
另外,用另一种方法,如果我尝试在我的
controlscript.js
中添加自定义页面,如下所示:
Controller.prototype.ReadyForInstallationPageCallback = function ()
{
try {
installer.addWizardPage(component, "CustomPage", QInstaller.ReadyForInstallation);
}
catch (e) {
QMessageBox.warning("QMessageBox", "", e, QMessageBox.Ok);
}
}
我收到此错误:
ReferenceError: component is not defined
所以,卸载应用程序时,看起来该组件根本没有加载。
从Qt文档我们只能在带有<UserInterfaces>
标签的组件xml文件中添加自定义页面。
安装过程中,
package.xml
和componentscript.js
完全有效,允许动态添加向导页面。[Installer/Uninstaller Process]
┌────────────────────┐ ┌──────────────────────────┐ ┌─────────────────────────┐
│ package.xml │ │ componentscript.js │ │ installscript.qs │
│ └─ UserInterfaces │──►│ └─ addWizardPage(...) │──►│ └─ Conditionall │
└────────────────────┘ └──────────────────────────┘ │ modify wizard │
│ ▲ └─────────────────────────┘
│ │ ▲
└──────────────────────────────┘ │
Installation Process │
Uninstallation Process
installscript.qs
注入在 both 安装和卸载期间运行的自定义逻辑(如本示例中的 )。installer.isUninstaller()
确定卸载过程是否正在进行,然后继续执行添加或修改向导页面的自定义逻辑。
您可以通过
installer.addWizardPage
为安装过程添加自定义页面。installscript.qs
中的可用挂钩与卸载过程进行交互。
在
installscript.qs
:
function Controller() {
// Constructor for script
}
Controller.prototype.IntroductionPageCallback = function() {
if (installer.isUninstaller()) {
// Custom logic for uninstallation, e.g., modifying the Introduction page
}
}