Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Qt Installer Framework : Create shortcut on the desktop
QtWS25 Last Chance

Qt Installer Framework : Create shortcut on the desktop

Scheduled Pinned Locked Moved Installation and Deployment
3 Posts 2 Posters 11.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    komates
    wrote on 22 Feb 2014, 18:14 last edited by
    #1

    Hello,

    I use Qt Installer framework 1.5

    After the installation, I would like to add a shortcut on the desktop.

    In my file installscript.qs, I tried :

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

    But it doesn't work, the shortcut isn't created and I don't have any error messages.
    The documentation on Internet is really light.

    Any idea ?
    Thank you

    1 Reply Last reply
    0
    • B Offline
      B Offline
      BorislavK
      wrote on 15 Jul 2014, 19:11 last edited by
      #2

      [SOLVED]
      Hey,

      I am not offering any solution but also seeking for one. As I am facing the same problem, I wondered if you were able to eventually figure out how to make the installer create a desktop shortcut. Any ideas or code that you are willing to share will be greatly appreciated.

      Thanks.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        BorislavK
        wrote on 19 Jul 2014, 17:51 last edited by
        #3

        komates: As far as I can see, the only difference between the code you posted and what works for me on Windows is that you used "createOperationsForPath" where I am using "createOperations". I have no idea if this makes any difference. I am posting a solution that worked fine for me on both Windows and Ubuntu.

        The complete code in my installscript.qs looks like:

        @function Component()
        {
        }
        Component.prototype.isDefault = function()
        {
        return true;
        }
        Component.prototype.createOperations = function()
        {
        try
        {
        component.createOperations();
        }
        catch (e)
        {
        print(e);
        }
        if (installer.value("os") === "win")
        {
        component.addOperation("CreateShortcut", "@TargetDir@/YourApp.exe", "@DesktopDir@/YourApp_name.lnk");
        }
        if (installer.value("os") === "x11")
        {
        component.addOperation("CreateDesktopEntry", "/usr/share/applications/YourApp.desktop", "Version=1.0\nType=Application\nTerminal=false\nExec=@TargetDir@/YourApp.sh\nName=YourApp_name\nIcon=@TargetDir@YourApp_icon.png\nName[en_US]=YourApp_name");
        component.addElevatedOperation("Copy", "/usr/share/applications/YourApp.desktop", "@HomeDir@/Desktop/YourApp.desktop");
        }
        }@

        The first "if" statement is for Windows. It creates a desktop shortcut YourApp_name.lnk for the executable YourApp.exe. Here, YourApp_name is the text that will actually show up under the desktop icon and you may want to make it slightly different from YourApp (e.g., your executable "slimImageViewer.exe" may sit better on the Desktop as "Slim Image Viewer.lnk" than it would as "slimImageViewer.lnk").

        The second "if" statement is used on Linux. The first function call creates a .desktop file in the standard location "/usr/share/applications" where it will be visible to the Dash search (I am familiar only with Ubuntu). The third argument is long string that lists the lines of the .desktop file separated by \n, i.e., "line1\nline2\nline3\n...\line10". Some familiarity with the general structure of a .desktop file would be helpful here.
        The second function call is create Windows-like experience. It places a copy of that .desktop file on the Desktop so that the user can launch the application by double-clicking a desktop icon.

        1 Reply Last reply
        3

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved