Thanks for the post - solved my problem. I decided to walk the controls such that normal Windows enter key behaviour could be implemented. So my handler looks like this:
void TextEdit
::keyPressEvent(QKeyEvent * in_pEvent
) {
switch (in_pEvent->key())
{
case Qt::Key_Return:
case Qt::Key_Enter:
{
// Find next button in tab order
while (!pButton)
{
focusNextChild();
pButton = dynamic_cast<QPushButton *>(parentWidget()->focusWidget());
}
// Click the button
pButton->click();
// Restore the focus
setFocus();
break;
}
default:
}
}
void TextEdit::keyPressEvent(QKeyEvent * in_pEvent)
{
switch (in_pEvent->key())
{
case Qt::Key_Return:
case Qt::Key_Enter:
{
// Find next button in tab order
QPushButton * pButton = NULL;
while (!pButton)
{
focusNextChild();
pButton = dynamic_cast<QPushButton *>(parentWidget()->focusWidget());
}
// Click the button
pButton->click();
// Restore the focus
setFocus();
break;
}
default:
QTextEdit::keyPressEvent(in_pEvent);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks