[Interest] emi enum type that defined in class of namespace

nus1998 nus1998 at yeah.net
Tue Feb 25 02:22:16 CET 2020


I have a piece of code like this:
namespace FOO_NS {
class FOO_CLASS : public QObject
    enum FOO_EM { EM_A, EM_B };

    void trigger(FOO_EM foo);
the signals doesn't work obviously as enum doesn't be registered. if I add Q_ENUM(FOO_EM) after the enum declaration, it doesn't work too. If I add Q_NAMESPACE and Q_ENUM_NS(FOO_EM) before/after the enum declaration respectively,  some errors encounters like "'const QMetaObject FOO_NS::FOO_CLASS::staticMetaObject' conflicts with a previous declaration". now the only work way that I have tried is that using qRegisterMetaType<FOO_NS::FOO_CLASS::FOO_EM>() to registered it, and change "void trigger(FOO_EM foo)" to "void trigger(FOO_NS::FOO_CLASS::FOO_EM foo)", which looks a bit ugly and I want to know is there more concise way to achieve it.

Thanks and best regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20200225/d2e9f0c4/attachment.html>

More information about the Interest mailing list