Class Platform#

Nested Relationships#

Nested Types#

Class Documentation#

class Platform#

The platform acts as a factory to create WindowAdapter instances.

Call slint::platform::set_platform() before creating any other Slint handles. Any subsequently created Slint windows will use the WindowAdapter provided by the create_window_adapter function.

Public Types

enum class Clipboard#

The type of clipboard used in Platform::clipboard_text and PLatform::set_clipboard_text.

Values:

enumerator DefaultClipboard#

This is the default clipboard used for text action for Ctrl+V, Ctrl+C. Corresponds to the secondary selection on X11.

enumerator SelectionClipboard#

This is the clipboard that is used when text is selected Corresponds to the primary selection on X11. The Platform implementation should do nothing if copy on select is not supported on that platform.

Public Functions

virtual ~Platform() = default#
Platform(const Platform&) = delete#
Platform &operator=(const Platform&) = delete#
Platform() = default#
virtual std::unique_ptr<WindowAdapter> create_window_adapter() = 0#

Returns a new WindowAdapter.

virtual std::chrono::milliseconds duration_since_start() = 0#

Returns the amount of milliseconds since start of the application.

This function should only be implemented if the runtime is compiled with SLINT_FEATURE_FREESTANDING

inline virtual void set_clipboard_text(const SharedString&, Clipboard)#

Sends the given text into the system clipboard.

If the platform doesn’t support the specified clipboard, this function should do nothing

inline virtual std::optional<SharedString> clipboard_text(Clipboard)#

Returns a copy of text stored in the system clipboard, if any.

If the platform doesn’t support the specified clipboard, the function should return nullopt

inline virtual void run_event_loop()#

Spins an event loop and renders the visible windows.

inline virtual void quit_event_loop()#

Exits the event loop.

This is what is called by slint::quit_event_loop() and can be called from a different thread or re-enter from the event loop

inline virtual void run_in_event_loop(Task)#

Run a task from the event loop.

This function is called by slint::invoke_from_event_loop(). It can be called from any thread, but the passed function must only be called from the event loop. Reimplements this function and move the event to the event loop before calling Task::run()

class Task#

An task that is passed to the Platform::run_in_event_loop function and needs to be run in the event loop and not in any other thread.

Public Functions

inline ~Task()#
Task(const Task&) = delete#
Task &operator=(const Task&) = delete#
inline Task(Task &&other)#

Move constructor. A moved from Task can no longer be run.

inline Task &operator=(Task &&other)#

Move operator.

inline void run() &&#

Run the task.

Can only be invoked once and should only be called from the event loop.