title: Qt: Defining a custom event type
body: <p>I have created a custom event in my Qt application by subclassing QEvent.  </p>
  
  <pre><code>class MyEvent : public QEvent
  {
    public:
      MyEvent() : QEvent((QEvent::Type)2000)) {}
      ~MyEvent(){}
  }
  </code></pre>
  
  <p>In order to check for this event, I use the following code in an event() method:</p>
  
  <pre><code>if (event-&gt;type() == (QEvent::Type)2000)
  {
    ...
  }
  </code></pre>
  
  <p>I would like to be able to define the custom event's Type somewhere in my application so that I don't need to cast the actual integer in my event methods.  So in my event() methods I'd like to be able to do something like</p>
  
  <pre><code>if (event-&gt;type() == MyEventType)
  {
    ...
  }
  </code></pre>
  
  <p>Any thoughts how and where in the code I might do this?</p>