2014-02-22 45 views
2

上创建快捷方式我使用Qt框架安装1.5Qt的安装框架:在桌面

安装完毕后,我想在桌面上添加快捷方式。

在我的文件installscript.qs,我想:

Component.prototype.createOperationsForPath = function() 
{ 
    if (installer.value("os") === "win") 
    { 
    try { 
     component.addOperation("CreateShortcut", "@[email protected]/App.exe", "@[email protected]/App.lnk"); 
    } 
    catch (e) { 
     print(e); 
    } 
    } 
} 

但它不工作,不创建快捷方式,我没有任何错误消息。 互联网上的文档真的很轻。

有什么想法? 谢谢

+0

尝试在函数的第一行添加'component.createOperations();'。 –

+0

它不起作用:/ –

+0

当您尝试在“开始”菜单上创建快捷方式时它工作吗?您是否将脚本添加到包XML文件中?你是否声明了组件(即'function Component(){}')? –

回答

7

试试这个。它为我工作。

Component.prototype.createOperations = function() 
{ 
    try { 
     // call the base create operations function 
     component.createOperations(); 
     if (installer.value("os") == "win") { 
      try { 
       var userProfile = installer.environmentVariable("USERPROFILE"); 
       installer.setValue("UserProfile", userProfile); 
       component.addOperation("CreateShortcut", "@[email protected]\\MiamPlayer.exe", "@[email protected]\\Desktop\\MiamPlayer.lnk"); 
      } catch (e) { 
       // Do nothing if key doesn't exist 
      } 
     } 
    } catch (e) { 
     print(e); 
    } 
}