On Monday 14 July 2014 21:47:00 Konstantin Tokarev wrote: > > 14.07.2014, 13:39, "Martin Koller" <kol...@aon.at>: > > On Monday 14 July 2014 09:11:06 Rutledge Shawn wrote: > >> On 12 Jul 2014, at 10:03 AM, Martin Koller wrote: > >>> Hi, > >>> > >>> is there any possibility to use an enum in the Q_ENUMS macro when the > >>> enum is not > >>> defined in a QObject derived class ? > >>> (Specifically I'm trying to do that with QSslError::SslError) > >> The Qt namespace has a lot of enums like that. The trick there is to get > >> moc to pretend that the namespace is actually a class. > >> > >> src/corelib/global/qnamespace.h > > > > This is not what I meant. > > The Qt namespace defines enums on its own and the MOC-Hack (#if > > defined(Q_MOC_RUN)) just makes sure that the enums > > can be used in Q_ENUMS > > > > What I need is a FOREIGN enum, e.g. one which is already availabe in a > > different Qt header, but the enum is not > > part of a QObject derived class. > > > > E.g. > > #include <QSslError> > > > > class MyClass : public QObject > > { > > Q_OBJECT > > Q_ENUMS(QSslError::SslError) // does not work > > }; > > > > #include "moc_test.cxx" > > > > In file included from test.cxx:9:0: > > moc_test.cxx:66:10: error: ‘staticMetaObject’ is not a member of ‘QSslError’ > > &QSslError::staticMetaObject, > > You can add fake poperty with type QSslError::SslError, and access enum via > QMetaProperty::enumerator()
That does not work. The doc says: "The enumeration type must be registered with the Meta-Object System using the Q_ENUMS() macro." but doing so leads to above compile error. Not using Q_ENUMS(QSslError::SslError) in MyClass does also not work, as QSslError::SslError is an enum from a class which is not QObject derived. The doc says: "Had the enumeration type been declared in another class, its fully qualified name (i.e., OtherClass::Priority) would be required, and that other class would also have to inherit QObject and register the enumeration type there using the Q_ENUMS() macro." -- Best regards/Schöne Grüße Martin A: Because it breaks the logical sequence of discussion Q: Why is top posting bad? () ascii ribbon campaign - against html e-mail /\ - against proprietary attachments Geschenkideen, Accessoires, Seifen, Kulinarisches: www.bibibest.at _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest