• QML鼠标拖动距离和速度


    import QtQuick 2.12
    import QtQuick.Window 2.12
    
    Window {
        visible: true
         640
        height: 480
        title: qsTr("Hello World")
    
        Rectangle {
            height: 40
             parent.width
            color: "red"
            anchors.top: parent.top
        }
    
        MouseArea {
               id: mouseArea
    
               // 滑屏动画
               /*! 第一次点击y坐标 */
               property int pressY: 0
               /*! 拖动总距离 */
               property int dragTotalChangedY: 0
               /*! 每次拖动启始y坐标 */
               property int dragStartY: 0
               /*! 每次拖动距离 */
               property int dragChangedY: 0
               property int distance: 40
               anchors.fill: parent
               enabled: true
    
               onPressed: {
                   dragStartY = mouseY
                   pressY = mouseY
                   console.info("pressY = ", pressY, "Screen.height * 0.01 = ", Screen.height * 0.01)
    
               }
    
               onMouseYChanged: {
                   // 边缘划入才拉起下拉面板,锁定及关机界面不唤起下拉面板
                   if (pressY - distance > 0)
                       return
    
                   dragChangedY = mouseY - dragStartY   // 每次拖动距离
                   dragStartY = mouseY                      // 每次拖动启始坐标
                   dragTotalChangedY = mouseY - pressY         // 拖动总距离
                   console.info("onMouseYChanged dragChangedY = ", dragChangedY)
                   console.info("onMouseYChanged dragTotalChangedY = ", dragTotalChangedY)
               }
    
               onReleased: {
                   if (pressY - distance > 0)
                       return
    
                   console.info("onReleased dragChangedY = ", dragChangedY)
                   console.info("onReleased dragTotalChangedY = ", dragTotalChangedY)
                   if (dragChangedY > Screen.height * 0.01) {
                       // 显示界面
                       console.info("111111111")
                       dragTotalChangedY = 0
                   } else if (dragChangedY < -Screen.height * 0.01) {
                       // 隐藏界面
                       console.info("2222222")
                       dragTotalChangedY = -Screen.height
                   } else {
                       // 超过屏幕一半显示,否则隐藏界面
                       dragTotalChangedY = (mouseY > (Screen.height / 2)) ? 0 : -Screen.height
                   }
    
                   if (0 === dragTotalChangedY) {
                       console.info("down")
                   } else {
                       console.info("invalid")
                   }
    
                   // 清除历史数据
                   dragChangedY = dragTotalChangedY = dragStartY = pressY = 0
               }
        }
    }
    
    
  • 相关阅读:
    未分类[selenium]常见元素定位
    未分类[selenium]-元素定位不到的原因及解决办法
    1.4测试需求分析
    1.3测试用例设计方法
    1.2软件生命周期&测试流程
    《Python 高级编程》简要读书笔记
    app基本测试要点总结
    python 找出两个列表的相同元素与不同元素
    mysql 8.0之后关于group by 语句报错问题
    selenium webdriver 执行原理
  • 原文地址:https://www.cnblogs.com/kuikuitage/p/15690569.html
Copyright © 2020-2023  润新知