3

I've started working with the Qt Installer Framework and find it useful except for the numerous undocumented features (e.g., setting the wizard subTitle or the existence of the DesktopDir variable) but one thing I haven't been able to figure out by code inspection is when you create a desktop shortcut how can you specify the shortcut icon?

I can create the desktop shortcut just fine with

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

where td and dd are the paths to the executable and link files respectively (but I haven't been able to make the installer operation

boolean performOperation(string name, stringlist arguments) 

work)

however I haven't been able to figure out how to set the desktop shortcut icon.

There must be a way because in the downloaded Qt Installer Framework installation the desktop shortcut icon isn't generic but is specified. I've tried looking at the code and in createshortcutoperation.cpp is the code

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

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

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

so I unsuccessfully tried

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

where iconPath is the path to the icon.

Does anyone know how Qt specifies their desktop shortcut icon?

Liviu
  • 1,859
  • 2
  • 22
  • 48
Paul Tarr
  • 251
  • 3
  • 9
  • 1
    Looking at source code they use `IShellLink` to set icons on Windows (hope you talking about Windows). It also seems that you must specify `iconId` parameter next to `iconPath`, try to set it to `1`, see [here](https://support.microsoft.com/en-us/kb/179904) for details. – dvvrd Dec 19 '15 at 15:26
  • Did not try it: http://doc.qt.io/qtinstallerframework/qt-installer-framework-startmenu-example.html, see the fifth parameter of `component.addOperation("CreateShortcut",` Your code seems proper and close to their given solution. – Liviu Apr 05 '17 at 12:43
  • Personally I do not need it as I am happy with the application's icon. – Liviu Apr 05 '17 at 12:44

1 Answers1

0
if (installer.value("os") === "win")
    component.addOperation("CreateShortcut", "@TargetDir@/assistant.exe", "@DesktopDir@/assistant.lnk");
}
Christian Gollhardt
  • 16,510
  • 17
  • 74
  • 111
enyang wu
  • 9
  • 1