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() -- Regards, Konstantin _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest