Complete API documentation for the SlintApp class.
- Core Methods
- Property Methods
- Callback Methods
- Global Singleton Methods
- Timer Methods
- Model Methods
- Style Methods
- Window Management Methods
- Component Introspection Methods
- File Dialog Methods (Desktop only)
- Message Dialog Methods (Desktop only)
- Notification Methods (Desktop only)
- Clipboard Methods (Desktop only)
- Hotkey Methods (Desktop only)
- System Tray Methods (Desktop only)
Loads and compiles a Slint definition from a file.
| Parameter | Type | Description |
|---|---|---|
cFile |
String | Path to the .slint file |
Returns: Self (for method chaining)
Example:
oApp = new SlintApp {
loadUI("main.slint")
}Loads and compiles a Slint definition from a source string.
| Parameter | Type | Description |
|---|---|---|
cSource |
String | Slint markup source code |
cPath |
String | Virtual path for resolving imports |
Returns: Self
Example:
cUI = '
export component App inherits Window {
Text { text: "Hello"; }
}
'
oApp = new SlintApp {
loadUIString(cUI, "virtual://app.slint")
}Creates a window instance from the loaded component definition. Call after loadUI/loadUIString if you need to recreate the window.
Returns: Self
Shows the window.
Returns: Self
Hides the window without destroying it.
Returns: Self
Runs the application event loop. This is a blocking call that returns when the window is closed or quit() is called.
Example:
oApp = new SlintApp {
loadUI("app.slint")
show()
run() // Blocks here until window closes
}Quits the application and exits the event loop.
Gets the native window pointer.
Returns: Window pointer
Gets the component definition pointer.
Returns: Component definition pointer
Sets a property value on the Slint component.
| Parameter | Type | Description |
|---|---|---|
cProp |
String | Property name |
value |
Any | Value to set (string, number, or list) |
Returns: Self
Example:
oApp.set("counter", 42)
oApp.set("title", "My App")
oApp.set("items", ["Apple", "Banana", "Cherry"])Sets a boolean property value.
| Parameter | Type | Description |
|---|---|---|
cProp |
String | Property name |
bValue |
Boolean | true/false or 1/0 |
Returns: Self
Sets a string property value. Always treats the value as a plain string with no type inference.
| Parameter | Type | Description |
|---|---|---|
cProp |
String | Property name |
cValue |
String | String value |
Returns: Self
Example:
oApp.setString("status-text", "File: icon.png not found")
oApp.setString("label", "#not-a-color")Sets a numeric property value.
| Parameter | Type | Description |
|---|---|---|
cProp |
String | Property name |
nValue |
Number | Integer or float value |
Returns: Self
Example:
oApp.setNumber("counter", 42)
oApp.setNumber("opacity", 0.5)Sets a color/brush property from a hex color string.
| Parameter | Type | Description |
|---|---|---|
cProp |
String | Property name |
cHex |
String | Hex color (#RRGGBB or #RRGGBBAA) |
Returns: Self
Example:
oApp.setColor("background", "#FF0000")
oApp.setColor("overlay", "#00000080")Sets an enum property value.
| Parameter | Type | Description |
|---|---|---|
cProp |
String | Property name |
cValue |
String | Enum in EnumName.variant format |
Returns: Self
Example:
oApp.setEnum("alignment", "TextHorizontalAlignment.center")Gets the current value of a property.
| Parameter | Type | Description |
|---|---|---|
cProp |
String | Property name |
Returns: Property value, or NULL if window not initialized
Example:
nCount = oApp.getProperty("counter")
? "Current count: " + nCountRegisters a Ring function as a callback for a Slint callback.
| Parameter | Type | Description |
|---|---|---|
cCallback |
String | Callback name defined in Slint |
cRingFunc |
String | Ring function name (use :funcName syntax) |
Returns: Self
Example:
oApp.setCallback("button-clicked", :onButtonClick)
func onButtonClick
? "Button was clicked!"Invokes a Slint function/callback programmatically.
| Parameter | Type | Description |
|---|---|---|
cCallback |
String | Function name to invoke |
aArgs |
List | Optional arguments |
Returns: Return value from Slint function, or NULL
Gets an argument passed to the current callback. Use inside a callback function.
| Parameter | Type | Description |
|---|---|---|
nIndex |
Number | 1-based index (first argument is 1) |
Returns: Argument value
Example:
func onValueChanged
newValue = oApp.callbackArg(1)
? "New value: " + newValueGets the number of arguments passed to the current callback.
Returns: Number of arguments
Gets a property value from a Slint global singleton.
| Parameter | Type | Description |
|---|---|---|
cGlobal |
String | Global name (e.g., "AppState") |
cProp |
String | Property name |
Returns: Property value
Sets a property value on a Slint global singleton.
| Parameter | Type | Description |
|---|---|---|
cGlobal |
String | Global name |
cProp |
String | Property name |
value |
Any | Value to set |
Returns: Self
Registers a callback on a Slint global singleton.
| Parameter | Type | Description |
|---|---|---|
cGlobal |
String | Global name |
cCallback |
String | Callback name |
cRingFunc |
String | Ring function name |
Returns: Self
Invokes a function on a Slint global singleton.
| Parameter | Type | Description |
|---|---|---|
cGlobal |
String | Global name |
cCallback |
String | Function name |
aArgs |
List | Optional arguments |
Returns: Return value
Starts a repeating timer.
| Parameter | Type | Description |
|---|---|---|
nInterval |
Number | Interval in milliseconds |
cCallback |
String | Ring function to call |
Returns: Timer ID
Example:
nTimerId = oApp.timerStart(1000, :onTick)
func onTick
? "Tick!"Starts a one-shot timer that fires only once.
| Parameter | Type | Description |
|---|---|---|
nInterval |
Number | Delay in milliseconds |
cCallback |
String | Ring function to call |
Returns: Timer ID
Stops a running timer.
| Parameter | Type | Description |
|---|---|---|
nTimerId |
Number | Timer ID |
Returns: Result of operation
Checks if a timer is currently running.
| Parameter | Type | Description |
|---|---|---|
nTimerId |
Number | Timer ID |
Returns: 1 if running, 0 if stopped
Restarts a stopped or running timer.
| Parameter | Type | Description |
|---|---|---|
nTimerId |
Number | Timer ID |
Returns: Result of operation
Changes the interval of an existing timer.
| Parameter | Type | Description |
|---|---|---|
nTimerId |
Number | Timer ID |
nInterval |
Number | New interval in milliseconds |
Returns: Result of operation
Models are used to populate Slint repeaters/lists with dynamic data.
Creates a new model and binds it to a property.
| Parameter | Type | Description |
|---|---|---|
cProp |
String | Property name to bind |
Returns: Model ID, or -1 on failure
Example:
nModelId = oApp.modelCreate("items")
oApp.modelPush(nModelId, ["text": "Item 1"])
oApp.modelPush(nModelId, ["text": "Item 2"])Appends an item to the end of a model.
| Parameter | Type | Description |
|---|---|---|
nModelId |
Number | Model ID |
value |
Any | Item value (typically a list/struct) |
Returns: Result of operation
Removes an item from a model by index.
| Parameter | Type | Description |
|---|---|---|
nModelId |
Number | Model ID |
nIndex |
Number | Zero-based index |
Returns: Result of operation
Updates an item in a model at a specific index.
| Parameter | Type | Description |
|---|---|---|
nModelId |
Number | Model ID |
nIndex |
Number | Zero-based index |
value |
Any | New value |
Returns: Result of operation
Gets an item from a model by index.
| Parameter | Type | Description |
|---|---|---|
nModelId |
Number | Model ID |
nIndex |
Number | Zero-based index |
Returns: Item value
Gets the number of items in a model.
| Parameter | Type | Description |
|---|---|---|
nModelId |
Number | Model ID |
Returns: Number of items
Removes all items from a model.
| Parameter | Type | Description |
|---|---|---|
nModelId |
Number | Model ID |
Returns: Result of operation
Inserts an item at a specific index.
| Parameter | Type | Description |
|---|---|---|
nModelId |
Number | Model ID |
nIndex |
Number | Zero-based index |
value |
Any | Item value |
Returns: Result of operation
Destroys a model and releases its resources.
| Parameter | Type | Description |
|---|---|---|
nModelId |
Number | Model ID |
Returns: Result of operation
Sets the widget style for subsequent compilations. Must be called before loadUI/loadUIString.
| Parameter | Type | Description |
|---|---|---|
cStyle |
String | Style name: "fluent", "material", "native", "cupertino", or "" for default |
Returns: Self
Example:
oApp = new SlintApp {
setStyle("material")
loadUI("app.slint")
}Gets the current widget style setting.
Returns: Current style name, or NULL if using default
Adds a library path for @library imports in Slint files. Must be called before loadUI/loadUIString.
| Parameter | Type | Description |
|---|---|---|
cName |
String | Library name (used in @name imports) |
cPath |
String | Filesystem path to the library |
Returns: Self
Removes a previously added library path.
| Parameter | Type | Description |
|---|---|---|
cName |
String | Library name |
Returns: Self
Clears all custom library paths.
Returns: Self
Moves the window to a specific screen position.
| Parameter | Type | Description |
|---|---|---|
nX |
Number | X coordinate in physical pixels |
nY |
Number | Y coordinate in physical pixels |
Returns: Self
Gets the current window position.
Returns: List [x, y] in physical pixels
Sets the window size.
| Parameter | Type | Description |
|---|---|---|
nWidth |
Number | Width in physical pixels |
nHeight |
Number | Height in physical pixels |
Returns: Self
Gets the current window size.
Returns: List [width, height] in physical pixels
Minimizes or restores the window.
| Parameter | Type | Description |
|---|---|---|
bMinimized |
Boolean | true to minimize |
Returns: Self
Returns: 1 if minimized, 0 otherwise
Maximizes or restores the window.
| Parameter | Type | Description |
|---|---|---|
bMaximized |
Boolean | true to maximize |
Returns: Self
Returns: 1 if maximized, 0 otherwise
Enables or disables fullscreen mode.
| Parameter | Type | Description |
|---|---|---|
bFullscreen |
Boolean | true for fullscreen |
Returns: Self
Returns: 1 if fullscreen, 0 otherwise
Gets the window's scale factor (for HiDPI displays).
Returns: Scale factor (e.g., 1.0, 1.5, 2.0)
Returns: 1 if visible, 0 if hidden
Requests a redraw of the window contents.
Returns: Self
Initiates window dragging for custom title bars. Call from a mouse-down event handler.
Returns: Self
Note: Not supported on Android.
Sets whether the window should stay above all other windows.
| Parameter | Type | Description |
|---|---|---|
bOnTop |
Boolean | true to keep on top |
Returns: Self
Note: Desktop only.
Sets the window icon from an image file.
| Parameter | Type | Description |
|---|---|---|
cIconPath |
String | Path to icon file (PNG recommended) |
Returns: Self
Note: Desktop only.
Gets the name of the loaded component.
Returns: Component name string
Gets a list of all properties defined in the component.
Returns: List of [name, type] pairs
Gets a list of all callback names defined in the component.
Returns: List of callback name strings
Gets a list of all public function names defined in the component.
Returns: List of function name strings
Gets a list of all global singleton names defined in the component.
Returns: List of global name strings
Note: Desktop only. Not available on Android.
Opens a file selection dialog.
| Parameter | Type | Description |
|---|---|---|
cTitle |
String | Dialog title |
Returns: Selected file path, or empty string if cancelled
Opens a file selection dialog with file type filters.
| Parameter | Type | Description |
|---|---|---|
cTitle |
String | Dialog title |
aFilters |
List | Filter list: [["Description", "ext1", "ext2"], ...] |
Returns: Selected file path
Example:
cFile = oApp.fileOpenWithFilters("Open File", [
["Text Files", "txt", "md"],
["Ring Files", "ring"]
])Opens a dialog for selecting multiple files.
Returns: List of selected file paths
Opens a multiple file dialog with filters.
Returns: List of selected file paths
Opens a file save dialog.
Returns: Selected save path
Opens a file save dialog with a default filename.
Returns: Selected save path
Opens a file save dialog with default name and filters.
Returns: Selected save path
Opens a folder selection dialog.
Returns: Selected folder path
Opens a dialog for selecting multiple folders.
Returns: List of selected folder paths
Note: Desktop only. Not available on Android.
Shows an information message box.
Returns: Self
Shows a warning message box.
Returns: Self
Shows an error message box.
Returns: Self
Shows a confirmation dialog with OK/Cancel buttons.
Returns: 1 if OK clicked, 0 if cancelled
Shows a Yes/No dialog.
Returns: 1 if Yes clicked, 0 if No clicked
Note: Desktop only. Not available on Android.
Shows a desktop notification.
| Parameter | Type | Description |
|---|---|---|
cSummary |
String | Notification title |
cBody |
String | Notification body text |
Returns: Self
Shows a notification with a custom timeout.
| Parameter | Type | Description |
|---|---|---|
nTimeout |
Number | Timeout in milliseconds |
Returns: Self
Shows a notification with a custom icon.
| Parameter | Type | Description |
|---|---|---|
cIcon |
String | Path to icon file |
Returns: Self
Shows a notification with icon and timeout.
Returns: Self
Note: Desktop only. Not available on Android.
Gets the current clipboard text content.
Returns: Clipboard text string
Sets the clipboard text content.
| Parameter | Type | Description |
|---|---|---|
cText |
String | Text to copy |
Returns: Self
Clears the clipboard contents.
Returns: Self
Note: Desktop only. Not available on Android.
Registers a global hotkey that works even when the app is not focused.
| Parameter | Type | Description |
|---|---|---|
cModifiers |
String | Modifiers: "ctrl", "alt", "shift", "super". Combine with +: "ctrl+shift" |
cKey |
String | Key code: "KeyA", "KeyB", "F1", "Space", "Enter", etc. |
cCallback |
String | Ring function to call |
Returns: Hotkey ID
Example:
nHotkey = oApp.hotkeyRegister("ctrl+shift", "KeyS", :onSaveHotkey)
func onSaveHotkey
? "Save hotkey pressed!"Unregisters a hotkey.
| Parameter | Type | Description |
|---|---|---|
nId |
Number | Hotkey ID |
Returns: Self
Unregisters all hotkeys.
Returns: Self
Polls for hotkey events. Call periodically (e.g., in a timer) to check for hotkey presses.
Returns: Self
Note: Desktop only. Not available on Android.
Platform implementations:
- Linux/BSD: Uses ksni (D-Bus/SNI protocol)
- Windows/macOS: Uses tray-icon (native APIs)
Creates a system tray icon with a tooltip.
| Parameter | Type | Description |
|---|---|---|
cTooltip |
String | Tooltip text |
Returns: Self
Creates a system tray icon with tooltip and custom icon.
| Parameter | Type | Description |
|---|---|---|
cTooltip |
String | Tooltip text |
cIconPath |
String | Path to icon file |
Returns: Self
Sets the tray icon image.
Returns: Self
Sets the tray icon tooltip.
Returns: Self
Adds a menu item to the tray context menu.
| Parameter | Type | Description |
|---|---|---|
cLabel |
String | Menu item label |
cCallback |
String | Ring function to call |
Returns: Menu item ID
Adds a separator line to the tray menu.
Returns: Self
Destroys the tray icon and menu.
Returns: Self
Polls for tray menu events. Must be called periodically to process menu item clicks.
Returns: Self
Example:
oApp.trayCreate("My App")
oApp.trayAddItem("Show", :onShow)
oApp.trayAddSeparator()
oApp.trayAddItem("Quit", :onQuit)
// Poll in timer
oApp.timerStart(100, :pollTray)
func pollTray
oApp.trayPoll()