实现按回车时,就进行某种功能

void DoWorkDialog::keyPressEvent(QKeyEvent  *keyEvent)
{
if (keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return) { 
if(m_getMathListResult.type().count() <= m_questionId)
return;


switch(m_getMathListResult.type().at(m_questionId).toInt()) {
case 2:
on_kouSuanSubmitButton_clicked();
break;


case 3:
on_countSubmitButton_clicked();
break;


case 4:
on_speakSubmitButton_clicked();
break;


case 5:
on_applicationSumitButton_clicked();
break;


default:
break;
}
}
}

你可能感兴趣的:(qt,按键事件)