How to create tree view in Slint #1042
-
Hello! I'm developing an application that needs a tree view, and I was wondering how I'd go about that on Slint. I could reasonably make Slint just take an array and recurse through it to draw each element... but I don't know how to recursively iterate through lists. I could also generate a list that's already been recursed through, but that seems suboptimal and not idiomatic. What would be a "correct" way to do this in Slint? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
related issue: #505 There is some implementation of a tree view already in Cargo UI: The way this work is that this is just a ListView, and the model contains the indentation level and some flag if it is open or not and show a open or close symbol. I think something similar could work for the official TreeView. |
Beta Was this translation helpful? Give feedback.
related issue: #505
There is some implementation of a tree view already in Cargo UI:
https://github.com/slint-ui/cargo-ui/blob/91bee62fbedad92b3fad4fc04d30c2ebb5d477ad/ui/cargo.slint#L179-L193
The way this work is that this is just a ListView, and the model contains the indentation level and some flag if it is open or not and show a open or close symbol.
Then there is some code in rust that "flatten" a tree into a model that is consumed by the ListView:
https://github.com/slint-ui/cargo-ui/blob/91bee62fbedad92b3fad4fc04d30c2ebb5d477ad/src/cargo.rs#L777
I think something similar could work for the official TreeView.