Important: Please read the Qt Code of Conduct -

Property assignment error

  • I have ListView and delegate:

        ListView {
            delegate: userListDelegate
            model: userList
    Component {
          id: userListDelegate
               onClicked: {
                   anotherComponent.user = userListView.currentItem // here I get Error: Cannot assign QObject* to User*

    userList is defined as:

    Q_PROPERTY(QQmlListProperty<User> userList READ userList NOTIFY userListChanged)

    and anotherComponent.user as:

    property User user

    Why I get Error: Cannot assign QObject* to User* ?

  • Could it be something simple like the User type not being a QObject? Also, just curious, why are you using a QQmlListProperty as your model? I don't see a need for it, but that could be because I'm just seeing a small snippet.

  • I got it!

    anotherComponent.user = model.modelData

Log in to reply