alltolove 发表于 2017-3-18 06:03:07

QT动画制作(二十七)

效果:

为了省事还是把MainForm.ui.qml删去,直接在main.qml文件敲代码:
import QtQuick 2.5
import QtQuick.Window 2.2

Window {
    visible: true
    width: 500
    height: 500
    title: qsTr("Hello World")
    Rectangle{
      id:ball
      width:140
      height: 140
      radius: 70
      color:"#00B000"
      Text{
            anchors.centerIn: parent
            text:"Qt"
            font.family: "Trebuchet MS"
            color:"white"
            font.pointSize: 54
      }
      SequentialAnimation{
            running: true
            PathAnimation{
                target:ball
                duration: 3000
                easing.type: Easing.Linear
                path: Path {
                  startX: 180; startY: 150//起始位置坐标

                  PathArc {
                        x: 179; y: 150//终止位置坐标
                        radiusX: 150; radiusY: 100//半径
                        useLargeArc: true
                  }
                }
            }
            ScaleAnimator{
                target:ball
                duration:3000
                from:1
                to:5.5
            }
      }
    }
}

Preview: 明天学习动态创建和销毁对象
页: [1]
查看完整版本: QT动画制作(二十七)