Registering custom event types
Solved
General and Desktop
-
Hello,
Is it safe to register custom event types beforemain()
? I have the code in a.so
, so I'm doing this in the header:class QMpiEvent : public QEvent { Q_GADGET public: QMpiEvent(Type, QtMpi::NodeId); static const Type NodeStarting; static const Type NodeExiting; };
And then I register the events in the .cpp:
const QEvent::Type QMpiEvent::NodeStarting = static_cast<QEvent::Type>(QEvent::registerEventType()); const QEvent::Type QMpiEvent::NodeExiting = static_cast<QEvent::Type>(QEvent::registerEventType());
Am I supposed to do the registration after the
QCoreApplication
has been initialized?Kind regards.
-
Hi,
Looking at the implementation of registerEventType, it seems you can call it before instantiating the QCoreApplication.
-
Doesn't seem so :) Or we both missed it :D