Qml翻转效果

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

使用Flipable, 根据状态改变进行翻转动画

    Flipable{
        id: flip
        width: 300
        height: 300
        anchors.centerIn: parent

        property bool flipped: false

        front:Image{
            anchors.fill: parent
            source: "qrc:/images/1.jpg"
        }

        back:Image{
            anchors.fill: parent
            source: "qrc:/images/2.jpg"
        }

        transform: Rotation{
            id: rotation
            origin.x: flip.width / 2
            origin.y: flip.height / 2
            axis.x: rx.checked
            axis.y: ry.checked
            axis.z: rz.checked
            angle: 0
        }

        states:State{
            PropertyChanges {
                target: rotation
                angle:180
            }
            when:flip.flipped
        }

        transitions: Transition{
            NumberAnimation{
                target:rotation
                properties: "angle"
                duration:1000
            }
        }
    }
show.gif

需要完整代码请访问QtQuickExamples

相关文章

网友评论

    本文标题:Qml翻转效果

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