键盘事件
#include <QKeyEvent>
按下
TODO
释放
鼠标事件
#include <QMouseEvent>
按下
void mousePressEvent(QMouseEvent *event);
- 判断鼠标键
void MainWindow::mousePressEvent(QMouseEvent *event) {
// 左键被按下
if (event->button() == Qt::LeftButton) {
// ...
}
// 右键被按下
if (event->button() == Qt::RightButton) {
// ...
}
}
释放
void mouseReleaseEvent(QMouseEvent *event);
移动
void mouseMoveEvent(QMouseEvent *event);