mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-28 21:04:47 +00:00
Fix number to string conversion in C++
This commit is contained in:
parent
486b2ab8f8
commit
5580b5112f
5 changed files with 90 additions and 59 deletions
|
@ -79,7 +79,7 @@ Hello := Rectangle {
|
|||
button_text: "+";
|
||||
}
|
||||
property<int32> counter;
|
||||
counter_label := Text { x: 100; y: 300; text: "0"; color: black; }
|
||||
counter_label := Text { x: 100; y: 300; text: counter; color: black; }
|
||||
ButtonRectangle {
|
||||
color: 4289374890;
|
||||
x: 50;
|
||||
|
|
|
@ -11,17 +11,11 @@ int main() {
|
|||
component.plus_clicked.set_handler([](auto...){
|
||||
auto &counter = component.counter;
|
||||
counter.set(counter.get() + 1);
|
||||
// FIXME: this _13 is an internal detail and should be private anyway. We muse use some
|
||||
// alias or way to expose the property (same for the _ before signals)
|
||||
component.counter_label_11.text.set(std::string_view(std::to_string(counter.get())));
|
||||
std::cout << "PLUS: " << std::string_view(component.counter_label_11.text.get()) << std::endl;
|
||||
});
|
||||
|
||||
component.minus_clicked.set_handler([](auto...){
|
||||
auto &counter = component.counter;
|
||||
counter.set(counter.get() - 1);
|
||||
component.counter_label_11.text.set(std::string_view(std::to_string(counter.get())));
|
||||
std::cout << "MINUS: " << std::string_view(component.counter_label_11.text.get()) << std::endl;
|
||||
});
|
||||
|
||||
sixtyfps::run(&component);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue