slint-ui/slint · error
Cannot get property
Error message
Cannot get property {name}: {e} What it means
Panic in live-preview's get_property when the interpreter instance cannot return the requested property value — typically the property does not exist or the caller supplied a value of the wrong type to deserialize into.
Solutions
- Verify the property name and its declared type; request the matching Rust type.
- Use the interpreter instance API (get_property returning Result) to handle the error gracefully instead of panicking.
- Re-load the component after .slint edits before reading properties.
- For globals, use get_global_property with the correct global and property names.
Example fix
// before
let n: i32 = live.get_property("items_count"); // property doesn't exist
// after
let n: i32 = live.get_property("item-count"); // match the declared property<int> item-count Defensive patterns
Strategy: try-catch
Validate before calling
// Check the property is declared before reading
// if instance.definition().properties(name).iter().any(|p| p.name == prop) { ... } Type guard
fn get_typed<T: TryFrom<Value>>(live: &LiveComponent, name: &str) -> Option<T> {
std::panic::catch_unwind(|| live.get_property(name)).ok().and_then(T::try_from).ok()
} Try / catch
match instance.get_property(name) {
Ok(v) => v,
Err(e) => { eprintln!("get_property {name} failed: {e}"); Value::default() }
} Prevention
- Use exact property names from the .slint source (kebab-case).
- Request the Rust type matching the declared property type.
- Re-load the component after edits before reading properties.
When it happens
Trigger: Calling LiveComponent::get_property with a name not present on the component, or a template/type mismatch between the requested Rust type and the property's declared type.
Common situations: Reading a property after a .slint edit renamed or removed it; querying a property that lives on a sub-element or global without the right name; asking for i32 when the property is a length (f32-like) or string.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- Cannot get property
- Cannot invoke callback
- Cannot invoke callback
- Cannot set callback
- Cannot set callback
AI-assisted analysis of slint-ui/slint@3a7e700487 (2026-09-16).
Data as JSON: /api/errors/31731f96dc15c0d1.
Report an issue: GitHub.
Appendix: source
Thrown at internal/live-preview/live_component.rs:194
/// Return the instance
pub fn instance(&self) -> &ComponentInstance {
self.instance.as_ref().expect("always set after Self is created from Rc::new_cyclic")
}
/// Set a property and remember its value for when the component is reloaded
pub fn set_property(&self, name: &str, value: Value) {
self.properties.borrow_mut().insert(name.into(), value.clone());
self.instance()
.set_property(name, value)
.unwrap_or_else(|e| panic!("Cannot set property {name}: {e}"))
}
/// Forward to get_property
pub fn get_property(&self, name: &str) -> Value {
self.instance()
.get_property(name)
.unwrap_or_else(|e| panic!("Cannot get property {name}: {e}"))
}
/// Forward to invoke
pub fn invoke(&self, name: &str, args: &[Value]) -> Value {
self.instance()
.invoke(name, args)
.unwrap_or_else(|e| panic!("Cannot invoke callback {name}: {e}"))
}
/// Forward to set_callback
pub fn set_callback(&self, name: &str, callback: Rc<dyn Fn(&[Value]) -> Value + 'static>) {
self.callbacks.borrow_mut().insert(name.into(), callback.clone());
self.instance()
.set_callback(name, move |args| callback(args))
.unwrap_or_else(|e| panic!("Cannot set callback {name}: {e}"));
}
/// forward to set_global_propertyView on GitHub (pinned to 3a7e700487)