I send this bug to Qt team: http://bugreports.qt.nokia.com/browse/QTBUG-13726 and here is the description:
QLineEdit/QTextEdit doesn't receive keyPressEvent on N97 I have a custom widget which inherits from QLinedEdit, in this widget I override event(QEvent * event), keyPressEvent(QKeyEvent *event) and keyReleaseEvent(QKeyEvent *event ). When I debugged the code on N97 device, when I press any key on the keypad the events are delivered as follows:
event(QEvent * events) gets called with event type set to KeyRelease.
keyReleaseEvent(QKeyEvent *event ) gets called.
and keyPressEvent was never called !!
if I press Enter, BackSpace, action keys, left, right, down, up, the events are delivered as follows:
event(QEvent * events) gets called with event type set to KeyPress.
keyPressEvent(QKeyEvent *event ) gets called.
event(QEvent * events) gets called with event type set to KeyRelease.
keyReleaseEvent(QKeyEvent *event ) gets called.
which is correct.
How to reproduce:
#include <QKeyEvent>
#include <QMessageBox>
#include <QLineEdit>
#include <QTextEdit>
#include <QDebug>
class MyWidget : public QLineEdit { Q_OBJECT public: MyWidget(QWidget *parent=0); void keyPressEvent(QKeyEvent * event); void keyReleaseEvent(QKeyEvent * event ); bool event(QEvent *event); };
MyWidget::MyWidget(QWidget *parent)
:QLineEdit(parent)
{ setText("Hola"); }
void MyWidget::keyPressEvent(QKeyEvent *event) { QLineEdit::keyPressEvent(event); }
void MyWidget::keyReleaseEvent(QKeyEvent *event ) { QLineEdit::keyReleaseEvent(event); }
bool MyWidget::event(QEvent *event ) {
switch( event->type() ) { case QEvent::KeyPress: QLineEdit::event(event); break; case QEvent::KeyRelease: QLineEdit::event(event); break; default: QLineEdit::event(event); }
}
The same problem appears if I inherits from the QTextEdit
and I've got this replay:
Isn't that just because of the input methods?
can anyone explain to me what he means by "input methods", and how it is related to the received events, I tried with setInputMethodHints() and inputMethodEvent() without success.