QML實現漸變側滑效果

用QML可以實現漸變滑出效果(從側邊慢慢滑出),效果不好截圖,可複製如下代碼到test.qml文件中(引入必要的頭,如import QtQuick 2.4 ^-^),然後用qmlscene.exe進行運行查看效果。

代碼如下:

Rectangle {
    id: root

    width: 300
    height: 500

    Rectangle {
        id: rect
        width: 200; height: parent.height
        color: "red"

        NumberAnimation {
            running: true
            target: rect;
            property: "x";
            from:root.width;
            to:root.width-rect.width;
            duration: 2000;
            easing.type: Easing.InOutExpo;  //Easing.InOutQuad; Easing.InOutCubic
            //loops: Animation.Infinite //Easing.InOutQuart;
        }
    }
}
用的QtQuick中的NumberAnimation控制變化的,其屬性easing.type可以設置他的彈出快慢效果變換。

發佈了58 篇原創文章 · 獲贊 83 · 訪問量 23萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章