Может кому пригодится.
C++ (Qt)
void MyWidget::keyPressEvent(QKeyEvent *e)
{
int keyInt = e->key();
QString seqStr = QKeySequence(e->key()).toString();
if ( seqStr.isEmpty() ||
keyInt == Qt::Key_Control ||
keyInt == Qt::Key_Alt || keyInt == Qt::Key_AltGr ||
keyInt == Qt::Key_Shift
)
{
return;
}
QStringList strSequence;
if (e->modifiers() & Qt::ControlModifier)
strSequence << "Ctrl";
if (e->modifiers() & Qt::AltModifier)
strSequence << "Alt";
if (e->modifiers() & Qt::ShiftModifier)
strSequence << "Shift";
QMessageBox::information(this,
"QKeySequence", strSequence.join(" + ") +
(strSequence.isEmpty() ? "" : " + ") +
seqStr);
}