Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
None
Description
Exhibit A
Code (adapted from the official example at https://doc.qt.io/qt-6/qml-qtqml-models-delegatemodel.html#groups-prop )
import QtQuick import QtQuick.Controls.Basic import QtQml.Models Window { width: 640 height: 480 visible: true ListView { anchors.fill: parent model: DelegateModel { model: ListModel { ListElement { name: "Apple" } ListElement { name: "Orange" } } groups: [ DelegateModelGroup { name: "selected" } ] delegate: Button { id: item width: 200 required property string name text: { let text = "Name: " + item.name if (item.DelegateModel.inSelected) text += ` (${item.DelegateModel.selectedIndex})` return text } onClicked: item.DelegateModel.inSelected = !item.DelegateModel.inSelected } } } }
Compiler output
Warning: Main.qml:30:29: Member "inSelected" not found on type "QQmlDelegateModelAttached" [missing-property] if (item.DelegateModel.inSelected) ^^^^^^^^^^ Warning: Main.qml:30:29: Could not compile binding for text: Cannot load property inSelected from QQmlDelegateModelAttached of QQmlDelegateModelAttached. [compiler] if (item.DelegateModel.inSelected) ^^^^^^^^^^ Warning: Main.qml:34:68: Member "inSelected" not found on type "QQmlDelegateModelAttached" [missing-property] onClicked: item.DelegateModel.inSelected = !item.DelegateModel.inSelected ^^^^^^^^^^ Warning: Main.qml:34:68: Could not compile binding for onClicked: Cannot load property inSelected from QQmlDelegateModelAttached of QQmlDelegateModelAttached. [compiler] onClicked: item.DelegateModel.inSelected = !item.DelegateModel.inSelected ^^^^^^^^^^
Exhibit B
Code (adapted from the official example at https://doc.qt.io/qt-6/qml-qtqml-models-delegatemodel.html#parts-prop )
import QtQuick import QtQml.Models Window { width: 640 height: 480 visible: true DelegateModel { id: visualModel delegate: Package { id: del required property string name Text { Package.name: "list" text: del.name } } model: ListModel { ListElement { name: "Apple" } ListElement { name: "Orange" } } } ListView { anchors.fill: parent model: visualModel.parts.list } }
Compiler output
Warning: Main.qml:29:28: Member "list" not found on type "QObject" [missing-property] model: visualModel.parts.list ^^^^ Warning: Main.qml:29:28: Could not compile binding for model: Cannot load property list from QObject of QQmlDelegateModel::parts with type QObject. [compiler] model: visualModel.parts.list ^^^^
Problems with current implementation
- The API is not tooling-friendly (e.g. the tools cannot understand `item.DelegateModel.inSelected` or `visualModel.parts.list`)
- The API is not very QML-ish
- It uses pseudo attached properties that cannot be bound to. The official documentation says, "Warning: In contrast to normal attached properties, those [of DelegateModel] cannot be set in a declarative way."
- DelegateModelGroup relies on many imperative functions. Furthermore, many of these functions take var and jsdict arguments.
Attachments
Issue Links
- is replaced by
-
QTBUG-71348 SortFilterProxyModel for QML (make QSortFilterProxyModel available)
- Open
- relates to
-
QTBUG-116992 Make PathAttribute attributes compilable by qmlsc
- Reported