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.[sls.gen.output]

The generated code contains a struct named after the exported component.[sls.gen.component]

An exported component shall inherit Window.[sls.gen.window-root]

pub fn new() -> Self
rust

Creates an instance of the component.[sls.gen.new]

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.[sls.gen.render-rgb8]

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.[sls.gen.render-error]

The struct holds the value of each property declared on the root element in a private field.[sls.gen.prop.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().[sls.gen.prop.names]

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.[sls.gen.prop.get]

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.[sls.gen.prop.set]

The Rust type T of a property maps from its Slint type:[sls.gen.prop.types]

Slint typeRust type
colorslint_sc::Color
lengthi32

© 2026 SixtyFPS GmbH