Need help for a TreeView
-
Hi,
I want to do something like the left part of the picture below (the tree with the yellow rectangle). First to do that I have to use TreeView right ?
If yes can someone explain me how ? Because I've looked Qt documentation and for TreeView I didn't get it how to use it so If you can help me thanks in advance ! -
Hi,
did you have a look at the QML Treeview docs
There is an example there.The picture you're a referring to is missing in your post. Can you add it? Then we can understand better what you want to do.
-
@Fheanor https://www.google.fr/search?q=arborescence&source=lnms&tbm=isch&sa=X&ved=0ahUKEwie0IjOtPbTAhUKJlAKHdl6DaEQ_AUICigB&biw=1920&bih=908#imgrc=IYXrqFXnP7ShfM:
I try with an url but it didn't work so here is a link to a photo on google image that show what I want.
-
I don't have an example that correspond to your example, but these are two examples of how you can use
Delegate
inside aTreeView
.- You can use the
itemDelegate property
of aTreeView
. This example will change the color of each line:
itemDelegate: Rectangle { color: ( styleData.row % 2 == 0 ) ? "white" : "lightblue" Text { anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left text: styleData.value // this points to the role we defined in the TableViewColumn below; which one depends on which column this delegate is instantiated for. } }
- You can also define a special
Delegate
for each column of yourTreeView
like that:
TableViewColumn { id : someColumn role: "someRole" title: someRole delegate : Rectangle { ... } }
Now you have to play with this to draw what you want
- You can use the
-
@Fheanor I have some assigning the model value, the example that you gave me the TableViewColumn part work but not the model one, Qt tell me that fileSystemModel doesn't exist. Actually I just want to add some "node" or p"parent" to my Treeview and of course some "children" I suppose it has a link with the model but I don't know how to do it. Hope it is more clear now. Thanks again for your time !