Skip to content

Generated Code

The Slint SC compiler translates a .slint file into Rust code that depends only on the slint-sc runtime crate.

The generated code contains a struct named after the exported component.

An exported component shall inherit Window.

pub fn new() -> Self
rust

Creates an instance of the component.

pub fn render_rgb8(&self, width: u32, height: u32, frame_buffer: &mut [u8]) -> Result<(), slint_sc::RenderError>
rust

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)?;
rust

When the length of frame_buffer isn’t width * height * 3, render_rgb8 returns Err(RenderError::InvalidFrameBufferSize) and paints nothing.

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().

pub fn get_foo(&self) -> T
rust

Returns the value of the property foo. It is generated for in, out, and in-out properties, but not for private ones.

pub fn set_foo(&mut self, value: T)
rust

Sets the value of the property foo. It is generated for in and in-out properties, but not for out and private ones.

The Rust type T of a property maps from its Slint type:

Slint typeRust type
colorslint_sc::Color
lengthi32

© 2026 SixtyFPS GmbH