Sunday, July 6th 2008, 12:09am UTC+1

You are not logged in.

  • Login
  • Register

1

Thursday, March 27th 2008, 1:45am

QVariant::setValue woes

QVariant::setValue is supposed to be able to set a QVariant to a custom class, thus

Source code

1
2
3
4
5
QVariant qv;

MyCustomClass mcc;

qv.setValue(mcc);


However, this generates an error:
error: 'qt_metatype_id' is not a member of 'QMetaTypeId<BinModel>'

The docs specifically say "struct" and not "class". While in my little c-brain structs are just classes with fields being default public instead of default private, this may in fact be the issue. Perhaps it literally needs to be a struct (which would be VERY inconvenient).

(The ultimate goal here is to reimplement the data() function for QAbstractTableModel, so my custom QItemDelegate can be rendered as a cell in my custom table.)

I am developing in XCode on a Mac, OS 10.5, if that matters.
  • Go to the top of the page

2

Thursday, March 27th 2008, 3:31am

I've tried this with multiple dummy custom classes and structs to no avail. Casting a pointer to any custom class as a (void *) builds fine though...a solution I found here:

http://lists.trolltech.com/qt-interest/2…ead01157-0.html
  • Go to the top of the page

Messenger

Intermediate

Posts: 325

Location: Lt

3

Thursday, March 27th 2008, 7:01am

RE: QVariant::setValue woes

Have you declared and registered custom metatype: http://doc.trolltech.com/4.3/qmetatype.html
Fighting fire with fire.
  • Go to the top of the page

4

Friday, March 28th 2008, 11:01pm

I did after I'd made this post. Took me a while but I seem to have figured it out =)

Thanks for getting back to me, in any case.
  • Go to the top of the page

Rate this thread