zoukankan      html  css  js  c++  java
  • Qt实现鼠标拖动窗口

    QPoint m_StartPoint; //鼠标按下起点
    bool m_bMousePress; //按下鼠标左键
    
    void CMyUpdateDlg::mouseMoveEvent(QMouseEvent *event)
    {
        //移动窗口
        if (m_bMousePress)
        {
            QPoint curPoint = event->globalPos();   //按住移动时的位置
            QPoint movePoint = curPoint - m_StartPoint;
    
         //普通窗口 QPoint mainWinPos
    = this->pos(); this->move(mainWinPos.x() + movePoint.x(), mainWinPos.y() + movePoint.y());

         //标题栏
         QPoint mainWinPos = QPoint(parentWidget()->x(), parentWidget()->y());
         QPoint pos = mainWinPos + movePoint;
         parentWidget()->move(pos);
    m_StartPoint
    = curPoint; } } void CMyUpdateDlg::mousePressEvent(QMouseEvent * event) { //只能是鼠标左键移动和改变大小 if (event->button() == Qt::LeftButton) { m_bMousePress = true; } //按下时鼠标左键时,窗口在屏幕中的坐标 m_StartPoint = event->globalPos(); } void CMyUpdateDlg::mouseReleaseEvent(QMouseEvent * event) { m_bMousePress = false; }
  • 相关阅读:
    python_request中params和data
    python_多线程加锁
    python_多线程join和setDaemon
    python_faker模块
    python_jsonpath模块
    MyBatis-自定义结果映射规则
    MyBatis-SELECT基本查询
    MyBatis-参数处理
    MyBatis-mybatis全局映射文件解析
    MySQL高级-主从复制
  • 原文地址:https://www.cnblogs.com/tingtaishou/p/13632136.html
Copyright © 2011-2022 走看看