"currentValue" is a read-only property of ComboBox
-
I am trying to run the (minimally modified) example for Model Roles on the ComboBox QML Type:
import QtQuick import QtQuick.Controls ApplicationWindow { width: 640 height: 480 visible: true // Used as an example of a backend - this would usually be // e.g. a C++ type exposed to QML. QtObject { id: backend property int modifier: Qt.NoModifier } ComboBox { model: [ { value: Qt.NoModifier, text: qsTr("No modifier") }, { value: Qt.ShiftModifier, text: qsTr("Shift") }, { value: Qt.ControlModifier, text: qsTr("Control") } ] textRole: "text" valueRole: "value" // Set currentValue to the value stored in the backend. currentValue: backend.modifier // When an item is selected, update the backend. onActivated: backend.modifier = currentValue } }Running this with
pyside6-qmlproduces the error Invalid property assignment: "currentValue" is a read-only property. This example is taken directly from the documentation. How can I set the value of the combo box? -
currentValueis writeable since Qt 6.10 only. -
currentValueis writeable since Qt 6.10 only. -
E eschutz has marked this topic as solved on