[EDIT: mostly a rant about an issue I’ve had while trying to implement this. I haven’t done everything I can yet though. Building KLeverNotes locally reveals that the Kirigami TreeView addons does work on my system, with your implementation. So there has to be something wrong with mine… might be a few more weeks before I find out what’s precisely wrong, but I’ll manage.]
Thanks ! It doesn’t seem like the Kirigami TreeView addon works for me.
I’ve made an implementation of QAbstractItemModel that works with Qt6’s TreeView, but when I use that implementation with Kirigami’s TreeView (and Qt5, since I’m using KF5), I end up with the following errors:
file:///usr/lib64/qt5/qml/org/kde/kirigamiaddons/treeview/styles/org.kde.desktop/TreeViewDecoration.qml:0: ReferenceError: kDescendantLevel is not defined
file:///usr/lib64/qt5/qml/org/kde/kirigamiaddons/treeview/styles/org.kde.desktop/TreeViewDecoration.qml:0: ReferenceError: kDescendantExpandable is not defined
file:///usr/lib64/qt5/qml/org/kde/kirigamiaddons/treeview/styles/org.kde.desktop/TreeViewDecoration.qml:0: ReferenceError: kDescendantExpanded is not defined
file:///usr/lib64/qt5/qml/org/kde/kirigamiaddons/treeview/styles/org.kde.desktop/TreeViewDecoration.qml:0: ReferenceError: kDescendantExpandable is not defined
file:///usr/lib64/qt5/qml/org/kde/kirigamiaddons/treeview/AbstractTreeItem.qml:134: ReferenceError: listItem is not defined
The last one was easy to fix: apparently, the implementation of AbstractTreeItem
MUST use listItem
as its id. That’s how it seems to work in your own implementation, and it does seem to work with mine as well.
I see that I can also define the kDescendantHasSiblings
, kDescendantExpanded
and kDescendantExpandable
properties myself: it removes the warning, and brings some visible changes to the view. However, it does not seem to work as intended, as trying to expand an item just clears the entire view.
Furthermore, I don’t see any of this in your implementation… so I’m pretty sure I shouldn’t be doing that. After exploring the code for Kirigami’s TreeView, I still have no clue where these properties are supposed to be coming from, and why they aren’t defined for me. It seems to me like they should be provided by the delegated component. But it’s not coming from AbstractTreeItem
, and since your implementation expands on this component, but still does not provide these properties… I just don’t get it !
Maybe I’m not using the right Kirigami version ? But my QML files import the 2.19 version, just like yours… and I’m building it with Qt 5.15, which I assume is not a problem.