Results 1 to 2 of 2

Thread: virtual keyboard and key press event

  1. #1
    Join Date
    Mar 2011
    Posts
    118
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default virtual keyboard and key press event

    Hi everyone,
    I have a virtual keyboard widget. I want to send key press event to the focused child widget of top widget from virtual keyboard.
    What i know for qt embedded QWSServer will do this work.(Am I correct ?)

    Can anybody suggest something ?

  2. #2
    Join Date
    Mar 2011
    Posts
    118
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: virtual keyboard and key press event

    I am trying to send keypress event to the focus widget.

    Qt Code:
    1. QKeyEvent keyEvent(QEvent::KeyRelease,keyId, Qt::NoModifier, text, false, 1);
    2. QCoreApplication::sendEvent(m_focusedWd, &keyEvent);
    To copy to clipboard, switch view to plain text mode 

    But it is not working.

    Same thing in a different way

    keyboard class:
    Qt Code:
    1. QKeyEvent keyEvent(QEvent::KeyRelease,keyId, Qt::NoModifier, text, false, 1);
    2. QCoreApplication::sendEvent(m_activeWindow, &keyEvent);
    To copy to clipboard, switch view to plain text mode 

    Mainwindow:
    Qt Code:
    1. QKeyEvent keyEvent(QEvent::KeyPress,event->key(),event->modifiers(),event->text(),false,1);
    2. QApplication::sendEvent(this->focusWidget(),&keyEvent);
    To copy to clipboard, switch view to plain text mode 

    It is working. I am able to send text to line edit.
    But problem is if I press enter then it will in infinite loop and after a while program will crash.

    But i tried QInputMethodEvent in keyboard class.
    Qt Code:
    1. ev.setCommitString(text);
    2. QCoreApplication::sendEvent(m_focusedWd,&ev);
    To copy to clipboard, switch view to plain text mode 

    I am able to set text only.
    How i will send backspace kind of special key ?

    Why keypress event is not able to send to focus widget ?

    thanks.

Similar Threads

  1. Want to detect keyboard key press other than modifier keys
    By Rajesh.Rathod in forum Qt Programming
    Replies: 3
    Last Post: 25th October 2013, 07:19
  2. How to get the virtual keyboard?
    By ramesh.bs in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 2nd June 2010, 11:58
  3. Paint event function in key press event
    By soumya in forum Qt Programming
    Replies: 6
    Last Post: 2nd February 2010, 12:40
  4. how to Simulate the keyboard press
    By duduqq in forum Qt Programming
    Replies: 3
    Last Post: 9th August 2008, 16:50
  5. like virtual keyboard?
    By triperzonak in forum Qt Programming
    Replies: 4
    Last Post: 10th July 2008, 16:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.