【问题标题】:Qt Installer Framework:How to specify the desktop shortcut icon?Qt Installer Framework:如何指定桌面快捷方式图标?
【发布时间】:2016-03-24 16:27:27
【问题描述】:

我已经开始使用 Qt 安装程序框架并发现它很有用,除了许多未记录的功能(例如,设置向导 subTitle 或 DesktopDir 变量的存在),但有一件事我无法弄清楚通过代码检查是在创建桌面快捷方式时如何指定快捷方式图标?

我可以很好地创建桌面快捷方式

component.addOperation("CreateShortcut",td,dd);

其中 td 和 dd 分别是可执行文件和链接文件的路径(但我一直无法进行安装程序操作

boolean performOperation(string name, stringlist arguments) 

工作)

但是我一直无法弄清楚如何设置桌面快捷方式图标。

必须有办法,因为在下载的 Qt Installer Framework 安装中,桌面快捷方式图标不是通用的,而是指定的。我试过查看代码,在 createshortcutoperation.cpp 中是代码

const QString iconId = takeArgument(QString::fromLatin1("iconId="), &args);

const QString iconPath = takeArgument(QString::fromLatin1("iconPath="), &args);

const QString workingDir = takeArgument(QString::fromLatin1("workingDirectory="), &args);

所以我尝试失败了

component.addOperation("CreateShortcut",td,dd,"iconPath="+iconPath);

其中 iconPath 是图标的路径。

有谁知道 Qt 如何指定他们的桌面快捷方式图标?

【问题讨论】:

  • 查看源代码,他们使用IShellLink 在 Windows 上设置图标(希望您谈论的是 Windows)。看来你必须在iconPath旁边指定iconId参数,尝试将其设置为1,详见here
  • 没试过:doc.qt.io/qtinstallerframework/…,见component.addOperation("CreateShortcut", 的第五个参数你的代码似乎正确并且接近他们给定的解决方案。
  • 我个人不需要它,因为我对应用程序的图标很满意。

标签: qt icons desktop qt-installer


【解决方案1】:
if (installer.value("os") === "win")
    component.addOperation("CreateShortcut", "@TargetDir@/assistant.exe", "@DesktopDir@/assistant.lnk");
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多