概述
- 要么看看有没有什么自带的方法设置屏蔽
- 重载 eventFilter来进行按键处理
重写 eventFilter事件
// bool m_bAltKeyPressedQEvent::Type type = event->type();switch (type) {case QEvent::KeyPress: {int key_type = static_cast<QKeyEvent*>(event)->key();if (key_type == Qt::Key_Alt)m_bAltKeyPressed= true;break;}case QEvent::KeyRelease: {int key_type = static_cast<QKeyEvent*>(event)->key();if (key_type == Qt::Key_Alt)m_bAltKeyPressed= false;break;}case QEvent::Close: {if (m_bAltKeyPressed) {//屏蔽ALT+F4event->ignore();return true;}}break;default:break;}