Hi again :)
I am trying to catch the escape key to trigger the cancellation when editing QLineEdits. I’ve subclassed and at the current moment the thing is simple enough:
myLineEdit::myLineEdit(QWidget *parent) :
QLineEdit(parent)
{
}
void myLineEdit::keyPressEvent(QKeyEvent *e)
{
qDebug() << Q_FUNC_INFO;
switch(e->key())
{
case Qt::Key_Escape:
qDebug() << Q_FUNC_INFO;
emit escapeKeyPressed();
default:
QLineEdit::keyPressEvent(e);
}
}
I know it’s working because while I am editing, I can see the qDebug() speech flowing, but if I press ESC it doesn’t print anything. So, I assume that it’s either ignoring ESC or that something else (maybe the main window?) is catching it before it gets to myLineEdit();
Any idea?
Thanks :)
↧