查看完整版本: [-- zhengtianzuo系列-Qml旋转箭头 --]

QTCN开发网 -> Qt代码秀 -> zhengtianzuo系列-Qml旋转箭头 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

zhengtianzuo 2017-10-18 14:40

zhengtianzuo系列-Qml旋转箭头

一个向右的箭头, 点击顺时针旋转90°, 再次点击逆时针旋转90°

```
Image {
        id: image
        height: 24
        width: 24
        anchors.centerIn: parent
        source: "qrc:/image.png"

        MouseArea{
            anchors.fill: parent
            onClicked:{
                if (rotationAnimation.running === true) return;
                rotationAnimation.start();
            }
        }
    }
    RotationAnimation{
        id: rotationAnimation
        target: image
        from: 0
        to: 90
        duration: 100
        onStopped: {
            if (isDown === true)
            {
                rotationAnimation.from = 0;
                rotationAnimation.to = 90;
            }
            else
            {
                rotationAnimation.from = 90;
                rotationAnimation.to = 0;
            }
            isDown = !isDown;
        }
    }
```



需要完整代码请访问 QtQuickExamples

big_mouse 2020-04-22 09:19


查看完整版本: [-- zhengtianzuo系列-Qml旋转箭头 --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled