slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.17k stars 582 forks source link

`SpinBox` should support `float`s #6207

Open Enyium opened 3 weeks ago

Enyium commented 3 weeks ago

I had a SpinBox that represented a percentage. But I needed increased precision. The only possibility with the current int-centric SpinBox was to present its values as per mille values. This is less intuitive for the end users, though.

It would be better, if SpinBox allowed for float values. Since this also changes the possible range of values, you may want to create a second widget, abstracting the common functionality into an internal widget.

EDIT: Obviously, the float SpinBox would need to have a way to specify the number of decimal places it should work with.

EDIT: See also: https://github.com/slint-ui/slint/issues/6240#issuecomment-2364032458.

FloVanGH commented 1 week ago

Hey, thanks again for the request. I think that make totally sense. On SpinBox that can support int and float, by configuration.

Enyium commented 1 week ago

On[e] SpinBox that can support int and float, by configuration.

But Slint doesn't have generics. Why try to be two things at the same time? Qt also differentiates between QDoubleSpinBox and QSpinBox. I think when different data types are output, there should be different widgets. Of course, it makes sense to use common code to implement them.

Also relevant: #1870.