Random values in the ui do not get updated #8095
-
Hello everyone, I am new to slint and I am trying to build a simple application which:
I am having trouble in my app, where some random values (mostly in Here my slint file:
And here the according rust code: // Prevent console window in addition to Slint window in Windows release builds when, e.g., starting the app via file manager. Ignored on other platforms.
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use std::error::Error;
use slint::ComponentHandle;
slint::include_modules!();
#[derive(Clone, Debug)]
pub struct Data {
pub a: Option<u32>,
pub b: u32,
pub c: i32,
pub d: i32,
pub s: String,
}
fn main() -> Result<(), Box<dyn Error>> {
let data = Data {
a: Some(4711),
b: 1337,
c: 42,
d: 7331,
s: String::from("Lorem Ipsum"),
};
// Create the main window.
let app_window = AppWindow::new().unwrap();
app_window.set_a(data.a.unwrap_or_default() as i32);
app_window.set_b(data.b as i32);
app_window.set_c(data.c);
app_window.set_d(data.d);
app_window.set_s(data.s.into());
app_window.on_button_pressed({
let ui_handle = app_window.as_weak();
move || {
let ui = ui_handle.unwrap();
let a = ui.get_a();
let b = ui.get_b();
let c = ui.get_c();
let d = ui.get_d();
let s = ui.get_s();
let result = Data {
a: Some(a as u32),
b: b as u32,
c: c,
d: d,
s: s.into(),
};
println!("{:?}", result);
}
});
// Run the application.
app_window.run()?;
Ok(())
} For whatever reason the only fields, that get updated in this scenario are Thanks in advance. P.S.: I also tried to omit the ´on_edited´ callback (in .slint), but this did not solve my issue. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I found the solution to my problem. Another case of rtfm, the default maximum values for Spin boxes are set to 100. Imho this is a little counter intuitive, as one would expect the control to work with any value out of the box. Don't you agree @ogoffart ? |
Beta Was this translation helpful? Give feedback.
I found the solution to my problem. Another case of rtfm, the default maximum values for Spin boxes are set to 100. Imho this is a little counter intuitive, as one would expect the control to work with any value out of the box. Don't you agree @ogoffart ?
Is there any reason why the min and max values cannot be set to int.min and min.max per default?