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
class SelectionDialog : public QDialog
To copy to clipboard, switch view to plain text mode
As a public function, it has:
void keyPressEvent( QKeyEvent* event );
To copy to clipboard, switch view to plain text mode
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:
{
break;
}
};
}
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;
}
};
}
To copy to clipboard, switch view to plain text mode
In the constructor of my class, I do this
setFocusPolicy( Qt::StrongFocus );
setFocus( Qt::PopupFocusReason );
setEnabled( true );
setFocusPolicy( Qt::StrongFocus );
setFocus( Qt::PopupFocusReason );
setEnabled( true );
To copy to clipboard, switch view to plain text mode
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?
Bookmarks