Getting Combobox options from SQLite database / table
-
Hi, I am trying to put entries from my SQLite table into a combobox as the options. can't get it working, this is my current code:
ComboBox { id: plate_empty width: 400 height: 100 anchors.centerIn: parent model: platesModel textRole: "plate" // Specifies which role contains the text to display onCurrentIndexChanged: { console.log("Selected plate:", plate_empty.currentText) } ListModel { id: platesModel Component.onCompleted: { // Fetch plates from the backend and populate the model TruckDatabase.get_all_plates().then(function(result) { platesModel.clear() for (var i = 0; i < result.length; i++) { platesModel.append({"plate": result[i]}) } }).catch(function(error) { console.log("Error fetching plates:", error) }) } } }
Anyone know a solution?