Need help deciding how to do things with listview
-
In my app I have a linked block/list like structure. (blocks follow one after another but can also contain lists of the same blocks inside themselves). They have different properties. I want to be able to add them and the edit they properties when I , for example, press on them. I made the structure in C++ but I don't know how to represent it in qml listview or something else. To put it simply I want model/something that can show block of different types with different properties that I can modify if I select them and that I can append to my model. Also there will be special blocks that will be able to contain more blocks in them,
-
Sounds more like a tree than a list.
You could separate the structure of the whole thing from the structure of a single block. The blocks would be represented in a tree and after clicking on a block you could list (and edit) the properties in a separate list. -
@Chris-Kawa Well, I'm on 5.4.1 and there is no tree view yet (I heard it will be in 5.5) so.. I mean I have the structure in my c++ files I just don't know how to properly represent/draw them in qml.
-
You can search the forum for qml treeviews. There's been some discussions about this in the past and some custom implementations presented. You might find something suiting you.
Some related topics or resources:
http://forum.qt.io/topic/50743/wip-c-qml-fully-recursive-treeview
http://www.codeproject.com/Articles/664041/QML-QtQuick-TreeView-Model-Part-II
https://www.qtdeveloperdays.com/sites/default/files/north-america/QtQuickTreeView.pdf -
@Chris-Kawa
Thanks.Btw, is there a way to make something OO like in qml? I mean from my point of view I have a bunch of objects with different properties, some of then even contain another such objects. And I'd want to be able to draw all of them with these properties but all delegate/role models imply that I have some common set of properties which is not the case. Isn't there a way to "bind" some c++ qt object to it's proper qml representation stating how it should be drawn?
For example, If I have object with int foo and QString bar property I'd like it to be drawn as Rectangle with foo and bar displayed inside of it.
And if I have object wich is a "node" i'd like to draw it as the on above but with all children to the right or inside.