【发布时间】:2019-11-16 19:49:29
【问题描述】:
关于 Qt 安装程序框架,我有一个问题:
如果当前在组件选择页面中选择了要安装的组件,我如何签入组件脚本?
没有相应的组件属性,我找不到可以查询的值。
【问题讨论】:
标签: qt qt-installer
关于 Qt 安装程序框架,我有一个问题:
如果当前在组件选择页面中选择了要安装的组件,我如何签入组件脚本?
没有相应的组件属性,我找不到可以查询的值。
【问题讨论】:
标签: qt qt-installer
你可以使用函数
component.componentChangeRequested();
component.installationRequested();
component.updateRequested();
component.uninstallationRequested();
查询有关请求的组件更改的信息。
所有这些功能都取决于包的先前状态。已卸载的已检查包将标记为installationRequested,已安装的未检查包将标记为uninstallationRequested,已安装版本低于捆绑版本的已检查包将标记为updateRequested。
更多信息请查看component Documentation。
【讨论】:
内置的installer 对象可以返回所有组件的列表。
见:https://doc.qt.io/qtinstallerframework/scripting-installer.html#components-method
“组件”对象具有installed 属性以及 Moose 在此处引用的方法。
见:https://doc.qt.io/qtinstallerframework/scripting-component.html
这里有一些有用的 QtScript 可以根据您的用例进行剪切、粘贴和修改:
function getComponent( name ) {
var comps=installer.components();
for( i=0; i< comps.length; i++ ) {
if( comps[i].name == name ) return comps[i];
}
throw new Error( "Component not found: " + name );
}
function isComponentInstalled( name ) {
try{ return getComponent( name ).installed; }
catch(e){ console.log( "Component not found: " + name ); }
return false;
}
function isComponentSelected( name ) {
try{ return getComponent( name ).installationRequested(); }
catch(e){ console.log( "Component not found: " + name ); }
return false;
}
【讨论】: