bruceariggs
10th October 2011, 17:39
I have a class that doesn't seem to override the keyPressEvent properly, or at least, the function isn't getting called.
It inherits from QDialog
class SelectionDialog : public QDialog
As a public function, it has:
void keyPressEvent( QKeyEvent* event );
Which is defined as:
void SelectionDialog::keyPressEvent( QKeyEvent* event )
{
switch( event->key() )
{
case Qt::Key_Up:
{
upClicked();
break;
}
case Qt::Key_Down:
{
downClicked();
break;
}
default:
{
QDialog::keyPressEvent( event );
break;
}
};
}
In the constructor of my class, I do this
setFocusPolicy( Qt::StrongFocus );
setFocus( Qt::PopupFocusReason );
setEnabled( true );
Yet when this dialog box launches in the program, no amount of key presses gets me into this function.
What am I missing or doing wrong?
It inherits from QDialog
class SelectionDialog : public QDialog
As a public function, it has:
void keyPressEvent( QKeyEvent* event );
Which is defined as:
void SelectionDialog::keyPressEvent( QKeyEvent* event )
{
switch( event->key() )
{
case Qt::Key_Up:
{
upClicked();
break;
}
case Qt::Key_Down:
{
downClicked();
break;
}
default:
{
QDialog::keyPressEvent( event );
break;
}
};
}
In the constructor of my class, I do this
setFocusPolicy( Qt::StrongFocus );
setFocus( Qt::PopupFocusReason );
setEnabled( true );
Yet when this dialog box launches in the program, no amount of key presses gets me into this function.
What am I missing or doing wrong?