在上一博客中详细介绍了QIFW如何使用自定义界面,那么接下来给大家分享一下如何使用自定义界面。刚好最近手上有一个需求,就是在安装的最后一个界面,即完成界面中添加一个复选框(是否运行),勾选复选框后,点击完成可以直接运行程序。
自定义UI的创建
自定义UI这块大家可以去看这条。
QIFW的自定义界面-优快云博客
具体逻辑实现
首先需要在Component中创建连接,使用Connect连接一下函数,然后主要部分的话:CompleteWidget 这个是UI的对象名,可以通过文本方式查看自己修改,其他的就简单了。
function Component()
{
component.loaded.connect(this, this.installerLoaded);
installer.finishButtonClicked.connect(this, Component.prototype.installationFinished);
}
Component.prototype.installationFinished = function()
{
console.log("enter installationFinished");
try {
console.log("enter installationFinished try ");
if (installer.isInstaller() && installer.status == QInstaller.Success) {
console.log("enter installationFinished try if ");
var CheckBoxChecked = component.userInterface( "CompleteWidget" ).checkBox.checked;
if (CheckBoxChecked) {
console.log("CheckBox 已选中");
var programPath = installer.value("TargetDir") + "/你的程序名";
console.log("give me the name:::"+ programPath);
installer.executeDetached(programPath);
}
else
{
console.log("CheckBox 未选中");
}
}
} catch(e) {
console.log(e);
}
}
有其他想法的朋友们可以在评论区交流,如果这篇文章对你有用的话,希望大家多多点赞支持。

被折叠的 条评论
为什么被折叠?



