Results 1 to 4 of 4

Thread: Qt on Linux and dead keys

  1. #1
    Join Date
    Dec 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qt on Linux and dead keys

    Hi,

    I have a QWidget which receives keypress events and shows the text received on the console (using qDebug() << event->text()).

    When I run the code on Windows, when pressing the dead key '`' followed by the 'a' key, the widget receives an event with the text() 'á', which is the right way.

    However, when running the same software on Linux, the widget receives two events, one with the text() '`' and another one with the text() 'a'.

    I tried enabling keyboard event compression but it didn't change the behaviour. The locale() seems to be the right one (at least the country and language are the right ones) and the rest of the apps that I run on Linux (like Qt Creator for instance) work as expected.

    Where can I look for the problem?

    Thanks in advance!

  2. #2
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qt on Linux and dead keys

    Does your console support output of such characters?

    This might be helpful.
    Last edited by SixDegrees; 17th December 2010 at 23:08.

  3. #3
    Join Date
    Dec 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt on Linux and dead keys

    My console (ctrl+alt+f1) and the emulators (xterm, gnome-terminal) work as expected (Ã instead of `a).

  4. #4
    Join Date
    Dec 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt on Linux and dead keys

    I have been researching a little and I found several differences between typical input widgets and my widget.

    If I use a QPlainTextEdit widget, everything works OK in my app. However, when using this widget and a QWidget next to it, while the QPlainTextEdit may receive "Ã ", the QWidget receives "`" followed by "a". I think that mayble using the right QInputMethod or locale or something may do the trick, but I'm not sure. Any ideas?

    Thanks!


    Added after 1 14 minutes:


    Fixed! Well, sort of...

    I had to set the Qt::WA_InputMethodEnabled attribute and, after that, reimplement the inputMethodEvent(QInputMethodEvent *e) method. This way, when receiving dead keys or some kind of special key events, the "input method" (ibus in my case, ubuntu) handles the special key event and lets the widget capture the text through the QInputMethodEvent::commitString() method.

    I hope it helps someone
    Last edited by Charletes; 20th December 2010 at 21:52.

Similar Threads

  1. FYI be careful with using dead code strip on OS X
    By manekineko in forum Qt Programming
    Replies: 1
    Last Post: 17th September 2010, 06:26
  2. signal to dead object
    By drhex in forum Qt Programming
    Replies: 2
    Last Post: 11th August 2009, 23:11
  3. Help! Program dead when changing input methed
    By vencent in forum Qt Programming
    Replies: 0
    Last Post: 24th April 2008, 11:55
  4. QHash with 2 keys?
    By MrGarbage in forum Qt Programming
    Replies: 5
    Last Post: 6th September 2007, 01:09
  5. Handling of dead keys in keyPressEvent()
    By ghorwin in forum Qt Programming
    Replies: 4
    Last Post: 2nd December 2006, 12:26

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.