Results 1 to 4 of 4

Thread: how to Simulate the keyboard press

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2008
    Posts
    41
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default how to Simulate the keyboard press

    when i press one button on the widget ,I want to Simulate the keyboard like press the key "PgDn" ,it will make the IE page down ,how can i do that,dose it must use the Xlib to do that ,and can you give me some code .

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to Simulate the keyboard press

    try this code.
    Qt Code:
    1. QKeyEvent key(QEvent::KeyPress, Qt::Key_PageDown, Qt::NoModifier); QApplication::sendEvent(widget_reciver, &key);
    2. if (key.isAccepted()) {
    3. //everything is ok
    4. } else {
    5. //something wrong
    6. }
    To copy to clipboard, switch view to plain text mode 
    read http://doc.trolltech.com/4.4/qcoreap...html#sendEvent and QKeyEvent for detailes.

  3. #3
    Join Date
    Apr 2008
    Posts
    41
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to Simulate the keyboard press

    Quote Originally Posted by spirit View Post
    try this code.
    Qt Code:
    1. QKeyEvent key(QEvent::KeyPress, Qt::Key_PageDown, Qt::NoModifier); QApplication::sendEvent(widget_reciver, &key);
    2. if (key.isAccepted()) {
    3. //everything is ok
    4. } else {
    5. //something wrong
    6. }
    To copy to clipboard, switch view to plain text mode 
    read http://doc.trolltech.com/4.4/qcoreap...html#sendEvent and QKeyEvent for detailes.
    thanks
    but in My app the widget_reciver is the FireFox or the openOffice or other app is not the Qt's QWidget.
    I don't know how to do that .

  4. #4
    Join Date
    Apr 2008
    Posts
    41
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to Simulate the keyboard press


Similar Threads

  1. On Screen Keyboard Problem
    By cutie.monkey in forum Qt Programming
    Replies: 1
    Last Post: 16th July 2008, 13:28

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.