Skip to content

How to create tree view in Slint #1042

Answered by ogoffart
rdrpenguin04 asked this question in Q&A
Discussion options

You must be logged in to vote

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.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rdrpenguin04
Comment options

Answer selected by rdrpenguin04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants