KeyPressEvent don't work with ibus?



  • 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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.