Qml旋转箭头

作者: zhengtianzuo | 来源:发表于2018-11-29 20:22 被阅读0次

    一个向右的箭头, 点击顺时针旋转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;
            }
        }
    
    show.gif

    需要完整代码请访问QtQuickExamples

    相关文章

      网友评论

        本文标题:Qml旋转箭头

        本文链接:https://www.haomeiwen.com/subject/vkkqcqtx.html