zoukankan      html  css  js  c++  java
  • Qt自定义一个事件类型

    继承QEvent类,在type()函数中调用QEvent::registerEventType()得到一个合法的eventType:

     1 class QCustomEvent : public QEvent
     2 {
     3 public:
     4     QCustomEvent() : QEvent(QCustomEvent::type())
     5     {}
     6 
     7     virtual ~QCustomEvent()
     8     {}
     9 
    10     static QEvent::Type type()
    11     {
    12         if (customEventType == QEvent::None)
    13         {
    14             int generatedType = QEvent::registerEventType()
    15             customEventType = static_cast<QEvent::Type>(generatedType);
    16         }
    17         return customEventType;
    18     }
    19 
    20 private:
    21     static QEvent::Type customEventType;
    22 };
    23 
    24 QEvent::Type QCustomEvent::customEventType = QEvent::None;
  • 相关阅读:
    activiti--操作例子
    activiti--服务表
    spring--加载资源文件
    Day17
    Day15
    Day14
    Day13
    Day12
    Day16
    Day11
  • 原文地址:https://www.cnblogs.com/wisdomroc/p/13397450.html
Copyright © 2011-2022 走看看