Hello,
i'm working on a large project and 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);
typedef qreal Ratio;
typedef qreal PositiveRatio;
typedef qreal NegativeRatio;
Q_DECLARE_METATYPE(Ratio);
Q_DECLARE_METATYPE(PositiveRatio);
Q_DECLARE_METATYPE(NegativeRatio);
To copy to clipboard, switch view to plain text mode
However, the compiler doesn't like it, and only accepts to register the first one.
My question is, how can i register metatypes based on the same underlying type as different types? What would be the trick if any?
Thanks,
Pierre.
[edit:] 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>()) {
spnBx->setRange(t==qMetaTypeId<PositiveRatio>() ? 0.0 : -1.0, t==qMetaTypeId<NegativeRatio>() ? 0.0 : 1.0);
spnBx->setSingleStep (.05);
return spnBx;
}
/* ... */
/* ... */
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;
}
/* ... */
To copy to clipboard, switch view to plain text mode
[/edit]
Bookmarks