QIFW中使用自定义UI安装完成后运行软件

在上一博客中详细介绍了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);
    }
}

有其他想法的朋友们可以在评论区交流,如果这篇文章对你有用的话,希望大家多多点赞支持。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值