PDA

View Full Version : QVariant custom type.



hickscorp
3rd May 2010, 15:23
Hello,

- In the same namespace (RE) i have two classes called CumulativeHistogram and BlackAndWhiteConverter respectivelly.
- Both classes herits QObject (Indirectly via abstract classes).
- Both classes have Q_OBJECT macro.
- After CumulativeHistogram declaration, i have "Q_DECLARE_METATYPE(RE::CumulativeHistogram)".
- In my BlackAndWhiteConverter class, i have:
Q_PROPERTY( const CumulativeHistogram* CumulativeHistogram READ cumulativeHistogram WRITE setCumulativeHistogram)

Now, from my main routine, i'm doing this:
bwc.setProperty("CumulativeHistogram", QVariant::fromValue<CumulativeHistogram*>(&histo));
bwc being an instance of BlackAndWhiteConverter, histo being a CumulativeHistogram, nothing happens. Qt tries to create the property, because it thinks it doesn't exist (See bellow why).

When setting breakpoints, the processor is going inside QMetaProperty::write, at the line:
vtypeName && strcmp(typeName, vtypeName) == 0it's comparing "const RE::CumulativeHistogram*" to "RE::CumulativeHistogram*"... But i can't declare my Q_PROPERTY as non-const, because it has to be.

The very strange thing is that if i call other properties of "scalar" types on a BlackAndWhiteConverter object (It has a few of type QRgb, unsigned char, etc), it works.

Anyone had this problem before?
Thanks,
Pierre.