Hi,
In the same page I have two separate ComboBoxes. Each ComboBox is populated from a different table from an SQLite db. The first ComboBox looks like this:
QQuick2.ComboBox {
id: medicationCombo
width: backgrnd.width / 2.7
height: dp(25)
anchors.bottom: medName.bottom
anchors.left: medName.right
anchors.leftMargin: dp(15)
font.pixelSize: 16
editable: true
textRole: "MednameField"
focus: true
//Displaying the first item from the db.
currentIndex: 0
model: ListModel {
id: listModel2
}
delegate: QQuick2.ItemDelegate {
width: medicationCombo.width
height: medicationCombo.height
//Defining the items in the dropdown list
Text {
id: medTxt
text: model.MednameField //This is not working.
font.pixelSize: 18
color: "#00008b"
anchors.verticalCenter: parent.verticalCenter
}
onClicked: medicationCombo.currentIndex = index
highlighted: medicationCombo.highlightedIndex === index
}
The second one:
QQuick2.ComboBox {
id: patientCombo
width: backgrnd.width / 2.7
height: dp(25)
anchors.bottom: name.bottom
anchors.left: name.right
anchors.leftMargin: dp(15)
font.pixelSize: 16
editable: true
textRole: "patientField"
focus: true
//Displaying the first item from the db.
currentIndex: 0
model: ListModel {
id: listModel
}
delegate: QQuick2.ItemDelegate {
width: patientCombo.width
height: patientCombo.height
//Defining the items in the dropdown list
Text {
id: ptnts
text: model.patientField
font.pixelSize: 18
color: "#00008b"
anchors.verticalCenter: parent.verticalCenter
}
When I use only 1 ComboBox on the page it works OK. When I have 2 I keep getting the following error message:
Unable to assign [undefined] to QString on line
text: model.MednameField //This is not working. How can I fix this? Thank you for your help.