views:

75

answers:

1

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:

  1. event(QEvent * events) gets called with event type set to KeyRelease.

  2. 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:

  1. event(QEvent * events) gets called with event type set to KeyPress.

  2. keyPressEvent(QKeyEvent *event ) gets called.

  3. event(QEvent * events) gets called with event type set to KeyRelease.

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

+1  A: 

On Symbian, the Window server sends key events to the FEP (Front End Processor) which in turn asks the control for its input capabilities (see http://developer.symbian.org/main/documentation/reference/s3/pdk/GUID-FCEDC338-61CA-5D10-A8DB-E44A3EBBDE5E-GENID-1-10-1-3-1-1-9-1-3-1.html, and TCoeInputCapabilities). I think this is what the comment to the bug report referred to.

The OfferKeyEventL functionality in Symbian is implemented as a Chain of Responsibility, which means that if a control in the chain can handle the key event, it is consumed and subsequent controls in the chain will not be aware of it.

So, either the event is discarded by the FEP due to input capabilities not being set (though I do not know how to set them through Qt) or the event is consumed earlier in the chain.

Fredrik H
thanks for your help, they have just confirmed the bug
Mahdi Hijazi