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 Component Struct
Section titled “The Component Struct”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() -> SelfCreates an instance of the component.[sls.gen.new]
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.[sls.gen.render-rgb8]
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.[sls.gen.render-error]
Properties
Section titled “Properties”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]
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.[sls.gen.prop.get]
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.[sls.gen.prop.set]
Property Types
Section titled “Property Types”The Rust type T of a property maps from its Slint type:[sls.gen.prop.types]
| Slint type | Rust type |
|---|---|
color | slint_sc::Color |
length | i32 |
© 2026 SixtyFPS GmbH