Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Property assignment error
Qt 6.11 is out! See what's new in the release blog

Property assignment error

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 783 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MartinD
    wrote on last edited by
    #1

    I have ListView and delegate:

        ListView {
            delegate: userListDelegate
            model: userList
        }
    Component {
          id: userListDelegate
    
           Button{
               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* ?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JordanHarris
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MartinD
        wrote on last edited by
        #3

        I got it!

        anotherComponent.user = model.modelData
        
        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved