[Qt-interest] typedef on the same underlying type and Q_REGISTER_METATYPE
MARTIN Pierre
hickscorp at gmail.com
Tue Sep 13 19:25:18 CEST 2011
Hello List,
i would like to be able to do as follows:
typedef qreal Ratio;
typedef qreal PositiveRatio;
typedef qreal NegativeRatio;
Q_DECLARE_METATYPE(Ratio);
Q_DECLARE_METATYPE(PositiveRatio);
Q_DECLARE_METATYPE(NegativeRatio);
However, the compiler doesn't like it, and only accepts to register the first one. So, how can i register metatypes based on the same underlying type as different types? What would be the trick if any?
Even if the underlying data type is the same, the typedefs on top of them should be considered as different...
The goal is to provide different edition widgets, like that, in my editors factory:
/* ... */
else if (t==qMetaTypeId<Ratio>() || t==qMetaTypeId<PositiveRatio>() || t==qMetaTypeId<NegativeRatio>()) {
QDoubleSpinBox *spnBx = new QDoubleSpinBox(p);
spnBx->setRange(t==qMetaTypeId<PositiveRatio>() ? 0.0 : -1.0, t==qMetaTypeId<NegativeRatio>() ? 0.0 : 1.0);
spnBx->setSingleStep (.05);
return spnBx;
}
/* ... */
Thanks,
Pierre.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110913/4aefc101/attachment.html
More information about the Qt-interest-old
mailing list