Function loadFile

  • Loads the given Slint file and returns an objects that contains a functions to construct the exported component of the slint file.

    The following example loads a "Hello World" style Slint file and changes the Text label to a new greeting: main.slint:

    export component Main {
    in-out property <string> greeting <=> label.text;
    label := Text {
    text: "Hello World";
    }
    }
    import * as slint from "slint-ui";
    let ui = slint.loadFile("main.slint");
    let main = new ui.Main();
    main.greeting = "Hello friends";

    Parameters

    • filePath: string

      A path to the file to load. If the path is a relative path, then it is resolved against the process' working directory.

    • Optional options: LoadFileOptions

      Use LoadFileOptions to configure additional Slint compilation aspects, such as include search paths, library imports, or the widget style.

    Returns Object

    The returned object is sealed and provides a property by the name of the component exported in the .slint file. In the above example the name of the property is Main. The property is a constructor function. Use it with the new operator to instantiate the component. The instantiated object exposes properties and callbacks, and implements the ComponentHandle interface. For more details about the exposed properties, see Instantiating A Component.

    Throws

    CompileError if errors occur during compilation.