title: Qt 4.8.4 Embedded Linux Handle Power Button Key Press
body: <p>I have a very simple Qt 4.8.4 embedded Linux app that runs on ARM. It basically just has an eventFilter installed at the qApp level. I have a Power Button on my board that emits 'code 116 (Power)' when pressed. </p>
  
  <p>Here is the output from evtest:</p>
  
  <pre><code># ./evtest /dev/input/event2
  Input driver version is 1.0.1
  Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0
  Input device name: "twl4030_pwrbutton"
  Supported events:
    Event type 0 (Sync)
    Event type 1 (Key)
      Event code 116 (Power)
  Testing ... (interrupt to exit)
  Event: time 1370431888.296539, type 1 (Key), code 116 (Power), value 1
  Event: time 1370431888.296539, -------------- Report Sync ------------
  Event: time 1370431888.453338, type 1 (Key), code 116 (Power), value 0
  Event: time 1370431888.453338, -------------- Report Sync ------------
  Event: time 1370431890.855651, type 1 (Key), code 116 (Power), value 1
  Event: time 1370431890.855682, -------------- Report Sync ------------
  Event: time 1370431891.026885, type 1 (Key), code 116 (Power), value 0
  Event: time 1370431891.026885, -------------- Report Sync ------------
  </code></pre>
  
  <p>Each time I press the button I get some output:</p>
  
  <pre><code># cat platform-omap_i2c.1-platform-twl4030_pwrbutton-event 
  �#�Qwat�#�Qwa�#�QY= t�#�QY=
  </code></pre>
  
  <p>I launch my app with '-qws' and my eventFilter is printing every event my Qt App gets:</p>
  
  <pre><code>// Install the event filter
  bool TestApp::eventFilter( QObject *obj, QEvent *ev ) {
  
      qDebug() &lt;&lt; ev-&gt;type();
  </code></pre>
  
  <p>The Event filter gets other touch and keypress events but never the (116) Power. So how do I get the Qt App to receive this event from Linux? Thanks!</p>
  
  <p>UPDATE:</p>
  
  <p>I've also implemented a filter that will intercept and report all events that the Qt QWS server receives. Here is my header file:</p>
  
  <pre><code>#include &lt;QApplication&gt;
  #include &lt;QDebug&gt;
  
  /// The QWS embedded server for OS events
  #include &lt;QWSServer&gt;
  
  /// For investigation key events
  #include &lt;QWSServer&gt;
  #include &lt;QWSMouseHandler&gt;
  #include &lt;QWSEvent&gt;
  
  class Filter : public QApplication
  {
  public:
  </code></pre>
  
  <p>Here is my implementation:</p>
  
  <pre><code>#include "filter.h"
  
  bool Filter::qwsEventFilter(QWSEvent *e)
  {
  
      qDebug() &lt;&lt; "NEW TYPE: " &lt;&lt; e-&gt;type;
  
  }
  
          Filter(int &amp;argc, char **argv ) : QApplication( argc, argv ) {};
  
          bool qwsEventFilter(QWSEvent * event);
  
      };
  </code></pre>
  
  <p>And here is main.c:</p>
  
  <pre><code>#include &lt;QApplication&gt;
  #include "filter.h"
  
  int main(int argc, char *argv[])
  {
  
      Filter a(argc, argv);
  
      return a.exec();
  }
  </code></pre>
  
  <p>I though that maybe QWS was gobbling up the power press event but after doing this qwsFilter I see that QWS is not receiving the Power Events at all!</p>