Generated Code
The Slint SC compiler translates a .slint file into Rust code that depends
only on the slint-sc runtime crate.
The Component Struct
Section titled “The Component Struct”The generated code contains a struct named after the exported component.
An exported component shall inherit Window.
pub fn new() -> SelfCreates an instance of the component.
render_rgb8()
Section titled “render_rgb8()”pub fn render_rgb8(&self, width: u32, height: u32, frame_buffer: &mut [u8]) -> Result<(), slint_sc::RenderError>Renders the window into frame_buffer as described in
Rendering:
width * height pixels in row-major order, each pixel three bytes — red,
green, blue.
let mut frame_buffer = [0u8; 320 * 240 * 3];instance.render_rgb8(320, 240, &mut frame_buffer)?;When the length of frame_buffer isn’t width * height * 3, render_rgb8
returns Err(RenderError::InvalidFrameBufferSize) and paints nothing.
Properties
Section titled “Properties”The struct holds the value of each property declared on the root element in a private field.
Kebab-case property names become snake_case in the generated names:
the accessors of a property foo-bar are get_foo_bar() and
set_foo_bar().
get_foo()
Section titled “get_foo()”pub fn get_foo(&self) -> TReturns the value of the property foo.
It is generated for in, out, and in-out properties,
but not for private ones.
set_foo()
Section titled “set_foo()”pub fn set_foo(&mut self, value: T)Sets the value of the property foo.
It is generated for in and in-out properties,
but not for out and private ones.
Property Types
Section titled “Property Types”The Rust type T of a property maps from its Slint type:
| Slint type | Rust type |
|---|---|
color | slint_sc::Color |
length | i32 |
© 2026 SixtyFPS GmbH