| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 2 | |
Hi again...
I have the following plain data class Point3D and want to
use as property. The docs says to have the type registered
first using Q_DECLARE_METATYPE() macro immediately
after the type have been declared.
I did precisely that and then I used the type (Point3D) as
a property for another class (Box). When I tried to introspect
an instance of Box, I got the following message :
"QMetaProperty::read: Unable to handle unregistered
datatype 'Point3D' for property 'Box::Position"
Am i missing something in the steps. Or should there be
more on Point3D class? The '>>' operator perhaps?
Last question: is this the appropriate forum to asks these
kind of questions? Or is there any other forum like qt-noob
or something ? :)
Thanks before... and here's the code
<code>
// The type
class Point3D {
// ... just a plain old C++ class with getters
// and setters and a toString() function.
// yep, I'm coming from Java :)
}
Q_DECLARE_METATYPE(Point3D) // ...registered the type right after declaration
// The class that uses the type as property
class Box : public QObject {
Q_OBJECT
Q_PROPERTY(Point3D Position READ getPosition)
public:
Box() {};
Point3D getPosition() const;
private:
Point3D position;
}
// The introspection process
Box b(1.0,1.0,1.0);
QMetaObject* meta = b.metaObject();
QMetaProperty metaProp = meta->property(1)
// '1' being the 'Position' property.
metaProp->read(&b);
// ^ this line is failing
</code>
Regards.
--
[ signature omitted ]
Barkah Yusuf Widodo wrote: >"QMetaProperty::read: Unable to handle unregistered >datatype 'Point3D' for property 'Box::Position" > >Am i missing something in the steps. Or should there be >more on Point3D class? The '>>' operator perhaps? You declared it with Q_DECLARE_METATYPE. Now you have to register it with qRegisterMetaType. -- [ signature omitted ]
Attachment:
signature.asc
Description: This is a digitally signed message part.