title: Simulating key press in C++ for use in QML for virtual keyboard
body: <p>For my QML based application I would like to have a virtual keyboard (Qt Enterprise is such a tease, but 200$&lt; is beyond my capabilities), so I decided to write my own. But I not quite sure how:</p>
  
  <p>Here is how I see the code:</p>
  
  <p><strong>keypress.h</strong></p>
  
  <pre><code>#ifndef KEYPRESS_H
  #define KEYPRESS_H
  
  #include &lt;QObject&gt;
  
  class KeyPress : public QObject
  {
  
      Q_OBJECT
  
  public:
      explicit KeyPress(QObject *parent = 0);
  
      Q_INVOKABLE void virtKeyPress(const int&amp; Char);
  
  signals:
      void virtKeyPressed(const int&amp; source);
  
  private:
      int vKey;
  };
  
  #endif // KEYPRESS_H
  </code></pre>
  
  <p><strong>keypress.cpp</strong></p>
  
  <pre><code>#include "keypress.h"
  #include &lt;QKeyEvent&gt;
  
  KeyPress::KeyPress(QObject *parent) :
      QObject(parent)
  {
  
  }
  
  void KeyPress::virtKeyPress(const int &amp;Char){
  
      vKey = Char;
      QKeyEvent event(QEvent::KeyPress, vKey, Qt::NoModifier);
      // Here I guess I should do somthing like "sendEvent(parent, &amp;event);" or whatever, but nothing seems to work.
      emit virtKeyPressed(vKey);
  
  
  }
  </code></pre>
  
  <p>I have a few ideas on how to inplement this in just qml, but where’s the fun in that. :)
  So I would like to ask for your guidance on the subject.
  Btw, I’ve searched through info on the web, yet no working code found.</p>