I need to do this for configuring my application. I have QLineEdit field with reimplemented keyPressEvent method.
QKeyEvent *ke = ...
QString txt;
if(ke->
Trying to capture a QKeySequence in keyPressEvent might not work as expect. And I found a solution:
// || event->type()== QEvent::ShortcutOverride is the key point
if (event->type() == QEvent::KeyPress || event->type()== QEvent::ShortcutOverride)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if (keyEvent->matches(QKeySequence::Save))
{
// Do save
}
}
I hope that helps someone. : )
Reference: QWidget::eventFilter() not catching key combinations