title: Qt keyPressEvent, "Hold", and keyReleaseEvent Handling with Buttons/Mouse Clicks
body: <p>I am writing a Qt program to simulate a piece of hardware and I would like to simulate button press, hold, and release events.  In my application, I'd like to handle input from both the keyboard and mouse clicks to make things convenient to the user (i.e. me).  I've noticed some odd behavior and I don't understand it.</p>
  
  <p>The application uses QPushButton with <code>autoRepeat</code> enabled and a 100 ms <code>autoRepeatDelay</code> and <code>autoRepeatInterval</code>.  If I <strong>mouse click</strong> on a button, I receive alternating "pressed" and "released" events.  I would have expected to see 1 to N-1 "pressed" events followed by a "released" event.  Why is Qt behaving that way?</p>
  
  <p>I've also implemented the following code to handle button presses from the <strong>keyboard</strong>:</p>
  
  <pre><code>void MyApp::keyPressEvent(QKeyEvent *event)
  {
      QString s = QString("My PRESS key is %1. The counter is %2").arg(event-&gt;text(), QString::number(keyCounter));
      qDebug() &lt;&lt; s;
      keyCounter++;
  }
  
  void MyApp::keyReleaseEvent(QKeyEvent *event)
  {
      QString s = QString("My RELEASE key is %1. The counter is %2").arg(event-&gt;text(), QString::number(keyCounter));
      qDebug() &lt;&lt; s;
      keyCounter = 0;
  }
  
  bool MyApp::eventFilter(QObject *obj, QEvent *event)
  {
      if (event-&gt;type() == QEvent::KeyPress)
      {
          this-&gt;keyPressEvent(dynamic_cast&lt;QKeyEvent*&gt;(event));
          return true;
      }
      else if (event-&gt;type() == QEvent::KeyRelease)
      {
          this-&gt;keyReleaseEvent(dynamic_cast&lt;QKeyEvent*&gt;(event));
          return  true;
      }
      else
      {
          return QObject::eventFilter(obj, event);
      }
  }
  </code></pre>
  
  <p>Here I see two types of behavior.  For alphanumeric keys, I see the alternating "pressed" and "released" events.  For arrow keys, I only see the "released" events.  Again, I would have expected to see 1 to N-1 "pressed" events followed by a "released" event.  Why do the arrow keys behave differently than the alphanumeric keys?</p>
  
  <p>Is what I'm trying to do possible in Qt?</p>