Askar
14th December 2009, 14:13
Dear Friends,
I need to override the Esc key event so i tried to reimplement keyPressEvent() of QDialog. but it is not executed when i pressed any key. the code is given below.
void Myclass::keyPressEvent(QKeyEvent *e)
{
if(e->key()==Qt::Key_Escape)
{
QMessageBox(0,"Error","Key press");
}
else
{
QDialog::keyPressEvent(e);
}
}
while defining QDialog i gave setFocusPolicy(Qt::StrongFocus) as like below
win = new QDialog(this);
QDialog::setFocusPolicy(Qt::StrongFocus);
can any body help me where im getting wrong
I need to override the Esc key event so i tried to reimplement keyPressEvent() of QDialog. but it is not executed when i pressed any key. the code is given below.
void Myclass::keyPressEvent(QKeyEvent *e)
{
if(e->key()==Qt::Key_Escape)
{
QMessageBox(0,"Error","Key press");
}
else
{
QDialog::keyPressEvent(e);
}
}
while defining QDialog i gave setFocusPolicy(Qt::StrongFocus) as like below
win = new QDialog(this);
QDialog::setFocusPolicy(Qt::StrongFocus);
can any body help me where im getting wrong