Replies: 1 comment 1 reply
-
So far I've gotten this to more or less working version with high precision decimals. Using slint float was resulting in (expected) floating point round-off error. in a nutshell... export global CMath {
out property <float> pi : 3.141592653589793;
pure callback decAdd(string, string) -> string;
}
// don't forget to re-export from your my_main_window.slint which is then implemented in .rs file ui_a.global::<CMath>().on_decAdd(
|a,b| {
let a_d = Decimal::from_str_exact(&a.to_string());
let b_d = Decimal::from_str_exact(&b.to_string());
let r = (a_d.unwrap() + b_d.unwrap());
return slint::SharedString::from(r.to_string());
}
); Would be nice to have decimals in slint, but I can't complain too much because you'll deal with same issues everywhere else (i.e .net). |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Base widget seems to support int only.
Is my best option to make my own spinbox?
Edit:
More general question: is slint base widget library kept deliberately simple and limited because developers are expected to roll their own widgets? I am totally ok with that, such a nice and flexible system so far.
Beta Was this translation helpful? Give feedback.
All reactions