[Development] Why does Q_ENUM() need qRegisterMetaType()?
vladstelmahovsky at gmail.com
Thu Jul 4 16:18:26 CEST 2019
isn't Q_ENUM is deprecated and now Q_ENUMS should be used instead? or vice
versa...always forgetting :)
On Thu, Jul 4, 2019 at 4:14 PM Olivier Goffart <olivier at woboq.com> wrote:
> On 04.07.19 12:43, Tom Isaacson wrote:
> >> The problem is that moc only generates the code that calls
> qRegisterMetaType if it sees Q_DECLARE_METATYPE. Actually, it does a bit
> more than that. It could as well do it for Q_ENUM type, just not
> implemented yet.
> >> We should consider doing it for all the types used in
> >> But it does not do it because that could be a potential breaking
> change for forward declared types.
> >> Maybe something for Qt6.
> > It's very confusing. You said yourself on
> https://woboq.com/blog/q_enum.html that "These enums are automatically
> declared as a QMetaTypes (no need to add them in Q_DECLARE_METATYPE
> anymore)." So Q_ENUM replaces Q_DECLARE_METATYPE and provides additional
> functionality but requires you to add an additional call to
> qRegisterMetaType? That seems backward.
> I know, the whole story behind Q_DECLARE_METATYPE and qRegisterMetaType
> is a
> bit confusing.
> Regarding Q_ENUM specifically, it could be fixed in moc, to be in the list
> the type that are declared.
> > Can I use Q_DECLARE_METATYPE and Q_ENUM and avoid qRegisterMetaType?
> Yes, youu can use both Q_DECLARE_METATYPE and Q_ENUM
> Development mailing list
> Development at qt-project.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Development