[Qt-interest] dynamic properties

David Boddie david.boddie at nokia.com
Fri Feb 6 16:20:02 CET 2009


ami guru wrote:

> "Dynamic properties are specific to an object. In other words, two objects
> of the same class can have a different list of dynamic properties. All
> objects of the same class share the same metaObject and thus, the same
> static properties."
> 
> "It is possible to store/load properties on a QObject without having them
> explicitly defined."
> 
>  The property name and value may not be necessary to be explicitly
>  defined.
> But what about their corresponding type.

The QVariant used to hold the value passed to QObject::setProperty()
contains type information. You also need to declare your custom type using
Q_DECLARE_METATYPE, as you appear to have done.

Please also note the information in the QMetaType documentation:

  "Any class or struct that has a public default constructor, a public copy
  constructor, and a public destructor can be registered."

  http://doc.trolltech.com/4.4/qmetatype.html#details

> Isnt that necessary for the type to be defined as well. If it is then is
> that in the following way:
> 
> **********************************''
> class SFVec3f
> {
[...]
> };
> 
> Q_DECLARE_METATYPE(SFVec3f)
> 
> *************************************

Doesn't your custom type work with dynamic properties? Can you tell us how
you tested it?

David
-- 
David Boddie
Senior Technical Writer
Nokia, Qt Software



More information about the Qt-interest-old mailing list