The problem after a recent update in my Ubuntu 13.10 with Unity.

When typing something in Qt Creator 3.0.1 or in my own program compiled with Qt 5.2.1 (from qt-project.org), I can't change keyboard layout. For example, if current layout was En when I launched the program, then only English letters will be typed in it, even if I switch to Russian language. If I press Alt+Shift, the tray icon does change from En to Ru, and it applies to most programs but not to some Qt programs. To change layout, I have to relaunch program or to use copy-paste from an input field in another program!

Not all Qt programs have this problem — for example, KDevelop doesn't.

Upgrading Ubuntu from 13.10 to 14.04 beta didn't solve this problem (while it fixed another bug, influencing shortcuts in Russian layout in LibreOffice).

What can cause this strange behavior?

  • Could you list more qt app which works and which having same problem? May be there is something common between them. (KDevelop build using KDE dev libs which are higher then Qt libs). Alse could add output of env | grep -i im – user.dz May 1 '14 at 7:28

It looks like it's a bug in Qt's event handling system for changing keynoard layout: bugzilla link.

Gatis Paeglis added a comment - 03/Dec/13 1:47 PM This is not a bug in Qt as suggested by a developer in https://mail.gnome.org/archives/desktop-devel-list/2013-September/msg00046.html The same resource suggests that the cause of the issue is that Qt doesn't listen for XkbNewKeyboardNotify events - this is wrong. XkbNewKeyboardNotify has nothing to do with keyboard layout changes. XkbNewKeyboardNotify event is fired when the actual hardware gets connected or disconnected, not when the keyboard layout changes. The actual issue is in Xlib as suggested in https://bugs.freedesktop.org/show_bug.cgi?id=23202 and in https://bugreports.qt-project.org/browse/QTBUG-30911. We can hope that one day xcb platform plugin won't need dependencies to Xlib anymore, which will allows us to use xcb event loop directly. This should also solve the "keyboard layout detection" issue. Here is the discussion about Xlib dependency in xcb plugin http://lists.qt-project.org/pipermail/development/2013-July/011965.html

As it's said, it affects only GTK based desktop enviroments, so you may want to swich to KDE. You can do it this way:

sudo apt-get install kubuntu-desktop

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.