Is there a cleaner way to register Qt custom events?
问题 I need to create several custom event classes for a Qt application. Right now, it looks like I will need to implement the following event type registration code for each event class: class MyEvent : public QEvent { public: MyEvent() : QEvent(registeredType()) { } static QEvent::Type eventType; private: static QEvent::Type registeredType(); } QEvent::Type MyEvent::eventType = QEvent::None; QEvent::Type MyEvent::registeredType() { if (eventType == QEvent::None) { int generatedType = QEvent: