Bind a checkbox to a QVariantMap
Unsolved
QML and Qt Quick
-
I have a listview that generates a set of checkboxes where the modelData from the list is displayed as the label for the checkbox. What I'd really like to do, is have the modelData be a QVariantMap which has the text and the checked state, but I can't get this to work. I don't know how to get the key/value pairs from the QVariant map
---- this works but is a simple list ---
ListView {
id: associatedVariablesListView
height: parent.height
width: parent.width
model: associatedVariableNames
anchors.top: lruOptionsCombo.bottomdelegate: CheckBox { id: cbx onCheckedChanged: updateCharts(this, modelData) clip: false height: 35 Text { font.pointSize: 8 anchors.left: cbx.right anchors.verticalCenter: cbx.verticalCenter text: modelData color: foregroundColor } }
}
---- this is what I want, but it doesn't work ---
ListView {
id: associatedVariablesListView
height: parent.height
width: parent.width
model: associatedVariableNames
anchors.top: lruOptionsCombo.bottomdelegate: CheckBox { id: cbx onCheckedChanged: updateCharts(this, modelData) clip: false height: 35 checked: modelData.value Text { font.pointSize: 8 anchors.left: cbx.right anchors.verticalCenter: cbx.verticalCenter text: modelData.key color: foregroundColor } }
}