Replies: 1 comment 1 reply
-
I now see that there's a import { ListView} from "std-widgets.slint";
export struct Box {
visible: bool,
}
export component Example inherits Window {
in property<[Box]> boxes: [{visible: false}, {visible: true},];
preferred-width: 50px;
preferred-height: 50px;
ListView {
for box[i] in root.boxes: Rectangle {
visible: box.visible;
height: 25px;
background: i == 0 ? blue : green;
}
}
} Seems related to #2516 Hacking up the workaround presented there to be something like the following for my scenario: import { ListView, Button } from "std-widgets.slint";
export struct Box {
visible: bool,
}
export component Example inherits Window {
in property<[Box]> boxes: [{visible: false}, {visible: true}, {visible: true}];
preferred-width: 50px;
preferred-height: 50px;
ListView {
for box[i] in root.boxes: HorizontalLayout {
if box.visible: HorizontalLayout {
width: self.preferred-width;
spacing: 5px;
Text {
text: "foo";
vertical-alignment: center;
}
Button {
text: "Click!";
}
}
}
}
} This unfortunately causes the application to hang with a sufficiently large number of conditional elements. |
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
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to implement a tree view where tree nodes that should not be visible have their
visible
flag set tofalse
. I'd like to check this in the slint code by doing something like the following:This results in a syntax error, however.
Is there a workaround that anyone can suggest?
Beta Was this translation helpful? Give feedback.
All reactions