Results 1 to 4 of 4

Thread: QKeyEvent problem with different keyboard layout

  1. #1
    Join Date
    Feb 2007
    Posts
    49
    Thanks
    4
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QKeyEvent problem with different keyboard layout

    I have this problem with keyPressEvent handler.

    Qt Code:
    1. void MainWindow::keyPressEvent(QKeyEvent *e)
    2. {
    3. if (e->key() == Qt::Key_N) {
    4. //do some stuff
    5. }
    6.  
    7. QMainWindow::keyPressEvent(e);
    8. }
    To copy to clipboard, switch view to plain text mode 

    When my keyboard layout is English, when I press 'N' it's working ok, but when I change the layout to some other language (in my case macedonian) I don't receive that I'm pressing the 'N' button. (if statement fails)

    Anyone know why is this? Is this a bug? Solution?

    Thanks in advance,
    Toni

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QKeyEvent problem with different keyboard layout

    What is the key you receive using the other layout? Just check the value of e->key() for that.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  3. #3
    Join Date
    Feb 2007
    Posts
    49
    Thanks
    4
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QKeyEvent problem with different keyboard layout

    It's 1053 which is Cyrillic 'N'.

    Now I am using QKeyEvent::nativeVirtualKey() which returns 'N' regardless of keyboard layout, but I am not sure is this very portable.

  4. #4
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QKeyEvent problem with different keyboard layout

    Only one way to find out, I think.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

Similar Threads

  1. Qt embedded Keyboard Plugin problem
    By abar9 in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 20th January 2010, 05:37
  2. Keyboard layout
    By alisami in forum Qt Programming
    Replies: 2
    Last Post: 20th October 2009, 07:31
  3. QKeyEvent Problem
    By cutie.monkey in forum Qt Programming
    Replies: 1
    Last Post: 25th July 2008, 23:36
  4. On Screen Keyboard Problem
    By cutie.monkey in forum Qt Programming
    Replies: 1
    Last Post: 16th July 2008, 13:28
  5. Keyboard shortcuts problem.
    By Lemming in forum Qt Programming
    Replies: 4
    Last Post: 5th April 2006, 16:12

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.