ComboBox text not getting changed.



  • Hello,
    I have a ComboBox, I want to change the Text in the ComboBox when the Button clicks. But when I click the button it shows an error "qrc:/main.qml:930: TypeError: Cannot assign to read-only property "currentText"" . Please support.

    The following code is used for the Button.

    Button {
    id: idNextButtonUser
    anchors{
    top: idRectangleInsideUserRegister.top
    left: idPrevButtonUser.right
    topMargin: idRectangleInsideUserRegister.height/6
    leftMargin: idRectangleInsideUserRegister.width/8.5
    }
    background: POS_FunctionButton {
    text: "Next"
    width: idRectangleInsideUserRegister.width/8
    height: idRectangleInsideUserRegister.height/3
    onClicked: {
    _userMaster.next()
    idTxtFieldUserName.text= _userMaster.UserName
    idComboBoxRole.currentText= _userMaster.Role
    }
    }
    }



  • @danild
    QComboBox::currentText is a read-only property returning the current text. QComboBox::setEditText() is what you need to use to set the text, as per http://doc.qt.io/qt-5/qcombobox.html#setEditText.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.