On 25/07/2019 06:20, Thiago Macieira wrote:
On Wednesday, 24 July 2019 09:05:02 PDT Nikos Chantziaras wrote:
On 24/07/2019 17:23, Thiago Macieira wrote:
On Tuesday, 23 July 2019 07:27:27 PDT Nikos Chantziaras wrote:
Ugh. Having the call happen on every object creation sounds even uglier.
It seems it's best to roll our own. Probably a lazily initialized global
static object that you can add functors to before main() and then run
all functors of that object in main().
Use qMetaTypeId<Type>(). That will include an inline check (runtime, sure)
whether it's already been registered.
That is a good solution for instantiable types, but for enums (my actual
use case) you can't do that.
Why not? Did you forget the Q_DECLARE_METATYPE?
I didn't (although I use Q_ENUM, but it does the same job.) But there's
no constructor to put qRegisterMetaType() in. It's an enum. There's no
constructor. Some enums are in a namespace, some are in a class, but
even with an enum that is in a class, users of can just use the enum in
their own signals/slots prior to instantiating the class that declares
the enum. It will stay unregistered until the first instance of the
class is created.
_______________________________________________
Interest mailing list
[email protected]
https://lists.qt-project.org/listinfo/interest