26 releases (stable)

1.8.0 Sep 23, 2024
1.7.1 Jul 25, 2024
1.5.1 Mar 20, 2024
1.3.2 Dec 1, 2023
0.3.2 Nov 28, 2022

#776 in GUI

Download history 9624/week @ 2024-08-22 8431/week @ 2024-08-29 10485/week @ 2024-09-05 10602/week @ 2024-09-12 11985/week @ 2024-09-19 12610/week @ 2024-09-26 12911/week @ 2024-10-03 10422/week @ 2024-10-10 12374/week @ 2024-10-17 10820/week @ 2024-10-24 12787/week @ 2024-10-31 7658/week @ 2024-11-07 2356/week @ 2024-11-14 2816/week @ 2024-11-21 3204/week @ 2024-11-28 2353/week @ 2024-12-05

11,190 downloads per month
Used in 15 crates (4 directly)

GPL-3.0-only…

2MB
32K SLoC

NOTE: This library is an internal crate of the Slint project. This crate should not be used directly by applications using Slint. You should use the slint crate instead.

WARNING: This crate does not follow the semver convention for versioning and can only be used with version = "=x.y.z" in Cargo.toml.

The Slint winit Backend

This crate implements the winit backend/platform for Slint. It is enabled by default as a default feature of the slint crate.

Although this crate is primarily internal, it can also be used by applications to leverage the full power of winit::window::Window for Slint Window.

To use this functionality, you need to be cautious when importing dependencies since this crate does not adhere to semver and may introduce breaking changes in any patch release. Additionally, the version of this crate must match the version of Slint. To indicate that you specifically want this version, include the = symbol in the version string.

Make sure that the version of winit matches the version used by this crate. Check this crate's dependencies to determine the required version.

[dependencies]
slint = { version = "x.y.z", ... }
i-slint-backend-winit = "=x.y.z"
winit = "0.w"

To ensure that the runtime backend is selected, initialize the backend as the first step in the main function:

fn main() {
    slint::platform::set_platform(Box::new(i_slint_backend_winit::Backend::new().unwrap()));
    // ...
}

Once you have a slint::Window (accessible through the window() function of the generated component), you can utilize the WinitWindowAccessor::with_winit_window function to access the winit::window::Window object.

# // similar to code generated by the slint! macro
# struct C; impl C { fn window(&self) ->i_slint_core::api::Window {todo!()} }
# let my_ui = C;
use i_slint_backend_winit::WinitWindowAccessor; // import the trait
my_ui.window().with_winit_window(|winit_window: &winit::window::Window| {
    // Here, you can use the winit API
});

Dependencies

~7–46MB
~776K SLoC