bool CDlgGlobalSettings::eventFilter(QObject *obj, QEvent *event){ if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); qDebug() << keyEvent->text(); return true; } // standard event processing return QObject::eventFilter(obj, event);
if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); if(keyEvent->modifiers() & Qt::ControlModifier) { qDebug() << "Ctrl+"; } if(keyEvent->modifiers() & Qt::ShiftModifier) { qDebug() << "Shift+"; } if(keyEvent->modifiers() & Qt::AltModifier) { qDebug() << "Alt+"; } qDebug() << keyEvent->text(); return true; }
C++ (Qt)if (keyEvent->modifiers().testFlag(Qt::ControlModifier)){ qDebug() << "Ctrl+";}