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. Pass object pointer throught c++ dataModel
Forum Updated to NodeBB v4.3 + New Features

Pass object pointer throught c++ dataModel

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 2 Posters 2.3k Views 1 Watching
  • 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
    Merinas
    wrote on last edited by
    #1

    Hi,

    I'm writting a C++ dataModel. I follow the documentation provided, so derived from QAbstractListModel. I defiend some role, one of them must be a pointer to a register type. But by passing throught the Qvariant, the QML side lose the type and it never recognise the true type.
    Did you have a solution or an idea ?

    Thanks

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dmcr
      wrote on last edited by
      #2

      Hello,

      Did you read this article "article":http://cdumez.blogspot.fr/2010/11/how-to-use-c-list-model-in-qml.html ?
      It was very helpfull for me!

      dmcr

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

        Thanks for the link, but I have no problem with this part. I just can't make it work when a property has pointer to register type for type. Due to QVariant which store a void* instread of Type*

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dmcr
          wrote on last edited by
          #4

          Did you use qmlRegisterType ?

          dmcr

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Merinas
            wrote on last edited by
            #5

            What I call a register type is a type on which I've used qmlRegisterType. So yes.
            The main purpose is to expose in a dataModel a type, which is an associative array like a QHash<QString, QVariant>.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dmcr
              wrote on last edited by
              #6

              I have done the same thing and it works fine, so could you post some code?

              dmcr

              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