Class Window#
Defined in File slint.h
Class Documentation#
-
class Window#
This class represents a window towards the windowing system, that’s used to render the scene of a component. It provides API to control windowing system specific aspects such as the position on the screen.
Public Functions
-
~Window() = default#
Destroys this window. Window instances are explicitly shared and reference counted. If this window instance is the last one referencing the window towards the windowing system, then it will also become hidden and destroyed.
-
inline void show()#
Registers the window with the windowing system in order to make it visible on the screen.
-
inline void hide()#
De-registers the window from the windowing system, therefore hiding it.
-
inline bool is_visible() const#
Returns the visibility state of the window. This function can return false even if you previously called show() on it, for example if the user minimized the window.
-
template<std::invocable<RenderingState, GraphicsAPI> F>
inline std::optional<SetRenderingNotifierError> set_rendering_notifier(F &&callback) const# This function allows registering a callback that’s invoked during the different phases of rendering. This allows custom rendering on top or below of the scene.
The provided callback must be callable with a slint::RenderingState and the slint::GraphicsAPI argument.
On success, the function returns a std::optional without value. On error, the function returns the error code as value in the std::optional.
- template<std::invocable F> inline requires (std::is_convertible_v< std::invoke_result_t< F >, CloseRequestResponse >) void on_close_requested(F &&callback) const
This function allows registering a callback that’s invoked when the user tries to close a window. The callback has to return a CloseRequestResponse.
-
inline void request_redraw() const#
This function issues a request to the windowing system to redraw the contents of the window.
-
inline slint::PhysicalPosition position() const#
Returns the position of the window on the screen, in physical screen coordinates and including a window frame (if present).
-
inline void set_position(const slint::LogicalPosition &pos)#
Sets the position of the window on the screen, in physical screen coordinates and including a window frame (if present). Note that on some windowing systems, such as Wayland, this functionality is not available.
-
inline void set_position(const slint::PhysicalPosition &pos)#
Sets the position of the window on the screen, in physical screen coordinates and including a window frame (if present). Note that on some windowing systems, such as Wayland, this functionality is not available.
-
inline slint::PhysicalSize size() const#
Returns the size of the window on the screen, in physical screen coordinates and excluding a window frame (if present).
-
inline void set_size(const slint::LogicalSize &size)#
Resizes the window to the specified size on the screen, in logical pixels and excluding a window frame (if present).
-
inline void set_size(const slint::PhysicalSize &size)#
Resizes the window to the specified size on the screen, in physical pixels and excluding a window frame (if present).
Dispatch a key press event to the scene.
Use this when you’re implementing your own backend and want to forward user input events.
The text is the unicode representation of the key.
Dispatch a key release event to the scene.
Use this when you’re implementing your own backend and want to forward user input events.
The text is the unicode representation of the key.
-
~Window() = default#