Cpper
C/C++高级工程师 Android高级软件工程师 IT集成工程师 音频工程师 熟悉c,c++,java,c#,py,js,asp等多种语言 程序猿
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtGraphicalEffects 1.0

Rectangle
{
    visible
: true
    width: 400
    height: 300

    Text
    {
        id: textID
        height: 240
        width: 240
        anchors.centerIn: parent
        text:"点击鼠标可旋转文字"
        verticalAlignment: Text.AlignVCenter
        horizontalAlignment: Text.AlignHCenter
        font.pointSize: 13

        MouseArea
        {
            anchors.fill: parent
            onClicked:
            {
                if(rotationAnimation.running === true)
                    return
;
                rotationAnimation.start();
            
}
        }

        LinearGradient
        
{
            source
: textID
            width: 240
            height: 240
            gradient: Gradient
            {
                GradientStop
                {
                    position: 0.0
                    color: "#22F222"
                
}
                GradientStop
                
{
                    position
: 0.9
                    color: "#F0280F"
                
}
            }
            start: Qt.point(0,0)
            end: Qt.point(240,240)
        }
    }

    RotationAnimation
    
{
        id
: rotationAnimation
        target: textID
        from: currentAngle
        to: currentAngle+diff
        duration: 100
        readonly property int diff: 5
        property int currentAngle: 0
        property bool isDown: true

        onStopped:
        {
            rotationAnimation.from = rotationAnimation.to
            rotationAnimation.to = rotationAnimation.to+diff
;
        
}
    }
}
posted on 2019-08-26 10:03 ccsdu2009 阅读(51) 评论(0)  编辑 收藏 引用 所属分类: QT编程

只有注册用户登录后才能发表评论。
【推荐】超50万行VC++源码: 大型组态工控、电力仿真CAD与GIS源码库
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理