0

I'm taking a look at the Qt installer framework, particularly the Start Menu Shortcut Example where I found

function Component()
{
    // default constructor
}

Component.prototype.createOperations = function()
{
    // call default implementation to actually install README.txt!
    component.createOperations();

    if (systemInfo.productType === "windows") {
        component.addOperation("CreateShortcut", "@TargetDir@/README.txt", "@StartMenuDir@/README.lnk",
            "workingDirectory=@TargetDir@", "iconPath=%SystemRoot%/system32/SHELL32.dll",
            "iconId=2", "description=Open README file");
    }
}

Looks like javascript (or Qt script) is in use here and I'm a little lost. In the code above, where does compoent comes from? Is it created by the function Component(){}?

I found the documentation saying

The script has to contain a Component object that the installer creates when it loads the script. Therefore, the script must contain at least the Component() function, which performs initialization

Is function Component(){} kind of a constructor?

KcFnMi
  • 5,516
  • 10
  • 62
  • 136
  • It is a constructor. A constructor function allows the assignment of `prototypes` to the object that will be constructed from the _constructor function_ using the `new` keyword. – Randy Casburn Feb 23 '21 at 06:00
  • May I ask you to expand on the "A constructor function allows the assignment of prototypes" part? Does it mean it necessary to call it in order for the "Component.prototype.createOperations = function() {...}" part to be executed? – KcFnMi Feb 23 '21 at 11:24
  • This answer should satisfy your question in more detail (and snarky distaste for JavaScript) than you will need: https://stackoverflow.com/questions/1595611/how-to-properly-create-a-custom-object-in-javascript/1598077#1598077 – Randy Casburn Feb 23 '21 at 14:56

0 Answers0