Results 1 to 3 of 3

Thread: Keyboard layout

  1. #1
    Join Date
    May 2008
    Posts
    61
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Keyboard layout

    Hi,

    I am running a Qt application on a system using an older version of the XServer. I cannot configure the keyboard layout on X, so I wonder if it is possible to change the keyboard layout internally in the Qt application.

    For example, when I press ';' on the keyboard, I want to capture the keyboard event, convert the keypress from ';' to a Turkish character and provide the new keyboard event to the application.

    Is it possible to do so or do I have to configure the XServer somehow to change the keyboard layout ?

    Sami

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Keyboard layout

    You can install an event filter on the application object so that you capture all events before they reach their destinations. Unfortunately after intercepting a key press event you will have to generate and deliver (probably using QCoreApplication::sendEvent()) the new key event yourself.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    alisami (20th October 2009)

  4. #3
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Keyboard layout

    our old code will help u a lot
    Qt Code:
    1. bool GraphView:: eventFilter(QObject *ob, QEvent *e)
    2. {
    3. if(e->type() == QEvent::KeyPress){
    4. printf("is it coming inside event..\n");
    5. const QKeyEvent *ke = static_cast<QKeyEvent *>(e);
    6. if(ke->key()== Qt::Key_A){ //check enum Qt::Key
    7. //do your modifications here
    8. printf("A button clicked..\n");
    9. }
    10. return true;
    11. }
    12. return QWidget::eventFilter(ob, e);
    13. }
    To copy to clipboard, switch view to plain text mode 
    "Behind every great fortune lies a crime" - Balzac

  5. The following user says thank you to wagmare for this useful post:

    alisami (20th October 2009)

Similar Threads

  1. Widget Virtual Keyboard
    By embitel in forum Qt-based Software
    Replies: 14
    Last Post: 12th July 2012, 11:22
  2. changing layout of a widget
    By mikro in forum Qt Programming
    Replies: 10
    Last Post: 4th August 2009, 21:21
  3. Qt like Layout Manager available for .NET platform
    By vkhaitan in forum Qt Programming
    Replies: 0
    Last Post: 5th November 2008, 14:36
  4. Qt layout memory issue
    By bunjee in forum Qt Programming
    Replies: 9
    Last Post: 25th August 2007, 18:11
  5. Resizing problems when applying a layout
    By JimBrown in forum Newbie
    Replies: 1
    Last Post: 21st February 2007, 23:54

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.