I have a QML ComboBox whose model is defined as a C++ QList < QObject* >. When I open the drop down list, I can see all items defined in the C++ model, but after selection, the selected item is not shown. So, items are only visible in the drop down element. The relevant part of the qml file is:
ComboBox {
id: placesCombo
anchors.top: parent.top
width: parent.width
model: myModel
delegate: ItemDelegate {
width: placesCombo.width
contentItem: Text {
id: placesComboItem
text: displayLabel
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
}
}
}
How to display in the closed combobox the item text previously selected in the drop down element?
According to the docs:
You have to indicate the role of the model to be displayed through textRole.