Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Simulating key press in C++ for use in QML for virtual keyboard.
Forum Updated to NodeBB v4.3 + New Features

Simulating key press in C++ for use in QML for virtual keyboard.

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Darkmalex
    wrote on last edited by
    #1

    Hi. For my QML based application I would like to have a virtual keyboard (Qt Enterprise is such a tease, but 200$< is beyond my capabilities), so I decided to write my own. But I not quite sure how:

    Here is how I see the code:

    keypress.h

    @#ifndef KEYPRESS_H
    #define KEYPRESS_H

    #include <QObject>

    class KeyPress : public QObject
    {

    Q_OBJECT
    

    public:
    explicit KeyPress(QObject *parent = 0);

    Q_INVOKABLE void virtKeyPress(const int& Char);
    

    signals:
    void virtKeyPressed(const int& source);

    private:
    int vKey;
    };

    #endif // KEYPRESS_H
    @

    keypress.cpp

    @#include "keypress.h"
    #include <QKeyEvent>

    KeyPress::KeyPress(QObject *parent) :
    QObject(parent)
    {

    }

    void KeyPress::virtKeyPress(const int &Char){

    vKey = Char;
    QKeyEvent event(QEvent::KeyPress, vKey, Qt::NoModifier);
    // Here I guess I should do somthing like "sendEvent(parent, &event);" or whatever, but nothing seems to work.
    emit virtKeyPressed(vKey);
    

    }
    @

    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.

    1 Reply Last reply
    0
    • mrdebugM Offline
      mrdebugM Offline
      mrdebug
      wrote on last edited by
      #2

      Please look at kde-app website. There are a lot of virtual keyboards already made.

      Need programmers to hire?
      www.labcsp.com
      www.denisgottardello.it
      GMT+1
      Skype: mrdebug

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Darkmalex
        wrote on last edited by
        #3

        [quote author="mrdebug" date="1406580379"]Please look at kde-app website. There are a lot of virtual keyboards already made.[/quote]

        I didn't quite understood what you ment by that.

        If you suppose I should use them "as is", that is a not a good idea (basicly impossible for what I'm doing).

        And if you suppose I should look through sourcecode... well most of the apps I already saw (about 4 or 5) are all widget based, and the worst part is that I'm stuck with qml for the moment.

        So any other ideas?

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved