Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Passing QML model



  • Hi,
    I have a QML component (it is a form which will edit user details). It exposes user property, where currently edited user sits:

    // UserEdit.qml
    
    Rectangle {
        property alias user: editedUser
    
        User {
            id: editedUser
        }
    }
    

    Then I have javascript code which should pass the user I wish to edit to the edit form:

    UserEdit{
       id: userEdit
    }
    
    // some components come here
    
    onClicked: {
       userEdit.user = model
    }
    

    However, during the assignment in onClicked event, I get:

    TypeError: Cannot assign to read-only property "user"
    

    How to pass the user to the edit form?


Log in to reply