【发布时间】:2020-06-02 04:29:07
【问题描述】:
我想在使用 Qt 安装框架完成安装后自动加载二进制文件。如何做到这一点?
我正在尝试编辑此脚本并添加 component.addOperation("CreateShortcut", "@TargetDir@/DistributionKit/Abc.sh");但它不会自动加载脚本。我错过了什么?
function Component()
{
installer.installationFinished.connect(this, Component.prototype.installationFinishedPageIsShown);
installer.finishButtonClicked.connect(this, Component.prototype.installationFinished);
}
Component.prototype.createOperations = function()
{
component.createOperations();
}
Component.prototype.installationFinishedPageIsShown = function()
{
try {
if (installer.isInstaller() && installer.status == QInstaller.Success) {
installer.addWizardPageItem( component, "ReadMeCheckBoxForm", QInstaller.InstallationFinished );
}
} catch(e) {
console.log(e);
}
}
Component.prototype.installationFinished = function()
{
try {
if (installer.isInstaller() && installer.status == QInstaller.Success) {
var isReadMeCheckBoxChecked = component.userInterface( "ReadMeCheckBoxForm" ).readMeCheckBox.checked;
if (isReadMeCheckBoxChecked) {
//QDesktopServices.openUrl("file:///" + installer.value("TargetDir") + "/Abc.sh");
component.addOperation("CreateShortcut", "@TargetDir@/DistributionKit/Abc.sh");
}
}
} catch(e) {
console.log(e);
}
}
【问题讨论】:
-
我总是使用您在代码中的注释:
QDesktopServices.openUrl("file:///....");和 .... 文件的绝对路径。就像您在示例中注释掉的那样。 -
但我不想加载任何 .txt 文件。我想加载一个二进制文件(操作系统:linux)
-
如果你想启动一个独立的程序。你可以试试
installer.executeDetached
标签: qt qt-installer