-
I have a top level component which is a TabWidget, where one tab is a component defined in another slint file. How do I set a property on that component? Do I have to write boilerplate in the top level component to pass it down to the child components? I tried calling set_ on the top level component but it says the struct doesn't have that method. What is the right way? P.D. Not sure if its the proper terminology, but I'm using the word top level to mean, the component that is exported by the slint file that Reduced Exampleimport { VerticalBox, Button } from "std-widgets.slint";
export component Pomodoro {
in-out property <bool> running;
in-out property <int> seconds;
VerticalBox {
Text {
text: seconds;
}
Button {
text: running ? "Start" : "Stop";
}
}
} import { ListView, TabWidget } from "std-widgets.slint";
import { Pomodoro } from "./pomodoro.slint";
export component MainWindow inherits Window {
default-font-size: 18pt;
preferred-height: 800px;
preferred-width: 600px;
TabWidget {
Tab {
title: "🍎d'oro";
Pomodoro { }
}
}
}
slint::include_modules!();
fn main() {
let win = MainWindow::new().unwrap();
win.set_seconds(300);
win.run().unwrap();
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You basically just need to make it a top-level property and forward it down the hierarchy of components. Alternatively, you might want to consider making it available as a property of an exported global singleton. |
Beta Was this translation helpful? Give feedback.
You basically just need to make it a top-level property and forward it down the hierarchy of components. Alternatively, you might want to consider making it available as a property of an exported global singleton.