Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. KeyPressEvent don't work with ibus?
Qt 6.11 is out! See what's new in the release blog

KeyPressEvent don't work with ibus?

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 703 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    albuseer
    wrote on last edited by
    #1

    Here is my code:
    @
    #include <QApplication>
    #include <QTextEdit>
    #include <QKeyEvent>

    class TextEdit : public QTextEdit {
    void keyPressEvent(QKeyEvent *e) {
    qDebug("pressed key %d", e->key());
    }
    void keyReleaseEvent(QKeyEvent *e) {
    qDebug("released key %d", e->key());
    }
    };

    int main(int argc, char *argv[]) {
    QApplication a(argc, argv);
    TextEdit e;
    e.show();
    return a.exec();
    }
    @

    The problem is, all text input are not captured by keyPressEvent when any ibus input method is on.
    I tested with ibus-pinyin and ibus-mozc and the only config it works is in mozc's direct input mode (not Latin mode, which buffers inputs inline and require a return to submit). ibus-pinyin's English mode also doesn't work.

    But it's strange that ASCII inputs in both ibus-pinyin's English mode and ibus-mozc's Latin mode are captured by keyReleaseEvent.

    -Is there any way to filter user input regardless of languages and input methods? How is Qt Creator's fakevim mode implemented?-

    My environment is GNOME 3.6.3 in Gentoo, with Qt 4.8.5 in Gentoo repo and Qt 5.1.1 downloaded from this site.

    Edit: I've found inputMethodEvent so the question is solved but it's still strange for text not captured in keyPressEvent being captured in keyReleaseEvent.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved