May 21, 2012

Merinas Merinas
Lab Rat
89 posts

Pass object pointer throught c++  dataModel

 

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

5 replies

May 21, 2012

dmcr dmcr
Ant Farmer
161 posts

Hello,

Did you read this article article [cdumez.blogspot.fr] ?
It was very helpfull for me!

May 21, 2012

Merinas Merinas
Lab Rat
89 posts

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*

May 21, 2012

dmcr dmcr
Ant Farmer
161 posts

Did you use qmlRegisterType ?

May 22, 2012

Merinas Merinas
Lab Rat
89 posts

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>.

May 22, 2012

dmcr dmcr
Ant Farmer
161 posts

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

 
  ‹‹ Image Gallery like bottom image gallery in android.      Centering of GridView and wrap around ››

You must log in to post a reply. Not a member yet? Register here!