1 //点击
2 void MainWindow::mousePressEvent(QMouseEvent *e)
3 {
4 if(e->button()==Qt::LeftButton)
5 {
6 this->setWindowTitle("left press");
7 }
8 else if(e->button()==Qt::RightButton)
9 {
10 this->setWindowTitle("right press");
11 }
12 else if(e->button()==Qt::MidButton)
13 {
14 this->setWindowTitle("mid press");
15 }
16 }
17
18 //移动
19 void MainWindow::mouseMoveEvent(QMouseEvent *e)
20 {
21 this->setWindowTitle(QString::number(e->x()) + "," + QString::number(e->y()) );
22 }
23
24 void MainWindow::mouseReleaseEvent(QMouseEvent *e)
25 {
26 this->setWindowTitle("Release " + QString::number(e->x()) + "," + QString::number(e->y()) );
27 }
28
29 void MainWindow::mouseDoubleClickEvent(QMouseEvent *e)
30 {
31 this->setWindowTitle("double click " + QString::number(e->x()) + "," + QString::number(e->y()) );
32 }