How to create fixed number of emlement from array? #4835
-
component A inherits Rectangle {
in-out property <[string]> all_data: [ "a", "b", "c", "d", "e", "f", "g", "h"];
VerticalBox {
for data in all_data: ??
}
} I want to display 3 data in a row, how to do it? I try to use GridBox, but it don't support 'for' loop. |
Beta Was this translation helpful? Give feedback.
Answered by
mitchgrout
Mar 13, 2024
Replies: 2 comments 1 reply
-
Sounds like you might be after repetition, e..g something like... VerticalBox {
for data in all_data: Text { text: "Your data is " + data; }
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
I want to like this: |
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
Hmm, I was thinking that something like this would be doable:
...but this triggers an error
'if' or 'for' expressions are not currently supported in grid layouts
:(One option would be to manually 'reshape' your array into that layout you want, e..g