日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

16.QT鼠标

發布時間:2023/11/27 生活经验 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 16.QT鼠标 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
  • 頭文件
    1 #include <QMouseEvent>
    2 #include <QStatusBar>
    3 #include <QLabel>
    1 protected:
    2     //鼠標按下
    3     void mousePressEvent(QMouseEvent *e);
    4     //鼠標移動
    5     void mouseMoveEvent(QMouseEvent *e);
    6     //鼠標釋放
    7     void mouseReleaseEvent(QMouseEvent *e);
    8     //鼠標雙擊
    9     void mouseDoubleClickEvent(QMouseEvent *e);

    ?

  • mainwindow.cpp
     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 }

    ?

轉載于:https://www.cnblogs.com/xiaochi/p/8746978.html

總結

以上是生活随笔為你收集整理的16.QT鼠标的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。