用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可以设置他的弹出快慢效果变换。