按键+按键组合,例如ctrl+字母:
1 void MyAPP::keyPressEvent(QKeyEvent *event) 2 { 3 if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_A)) 4 { 5 QMessageBox::aboutQt(NULL, "aboutQt"); 6 } 7 }
按键+鼠标组合,例如ctrl+左击:
1 void MyAPP::mousePressEvent(QMouseEvent *event) 2 { 3 if ((QApplication::keyboardModifiers() == Qt::ControlModifier) && (event->button() == Qt::LeftButton)) 4 { 5 QMessageBox::aboutQt(NULL, "aboutQt"); 6 } 7 }
时间: 2024-10-09 04:39:12