Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
None
-
None
-
21
-
Foundation PM Prioritized
Description
It's kindof obvious that we should make it easy to display JSON data in a QTreeView or Qt Quick TreeView. https://codereview.qt-project.org/c/qt/qtdoc/+/456602 is adding an example like that, but has to do it the hard way because we don't have library code for that.
But then again, most applications need to do something more specific, not just display all the data in its original form. For XML in Qt Quick, we have XmlListModel, supporting XPath queries. I wonder if there's a common JSON paradigm like that. https://stackoverflow.com/questions/8481380/is-there-a-json-equivalent-of-xquery-xpath
There's a QML TableModel but not yet a TreeModel. We know we should write one. But maybe it's better to write a nice C++ class first, get it working with QTreeView, and try to make it available to QML in the QtQml.Models module at the same time, testing it with TreeView. Alternatively, someone might want to process the JSON in QML/javascript first, and programmatically insert something into a TreeModel; so it would be nice if the same model can also be built up one-node-at-a-time, not only by parsing a JSON file to begin with.
We have QJsonDocument, QJsonArray and QJsonObject. A tree view could start with any of those as its root, depending whether you want to show the whole document or a subtree; so that would tend to make it a bit complicated. If the code gets too complex to support all of those cases, then I think maybe it points to an architectural improvement that we need in the QJson classes (and others): some sort of generic QTreeNode class (name TBD) that all those can inherit from. Then we could have a QTreeModel (TBD) that can make available any subtree (with one QTreeNode root) as a QAIM, and therefore available to all the views.
Attachments
Issue Links
- relates to
-
QTBUG-83615 Editable Tree Model Example is incomplete
- Reported
-
QTBUG-12117 Add support for JS arrays in ListModel
- Open
-
QTBUG-13688 Support lists of lists in XmlListModel
- Open
-
QTBUG-71348 SortFilterProxyModel for QML (make QSortFilterProxyModel available)
- Open
-
QTBUG-44226 Differnt parsing modes for QJsonDocument
- Open
-
QTBUG-61630 Provide TreeView in QtQuick
- Closed