热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

QML(13)——文字跑马灯实现

一、效果二、代码importQtQuick2.0importQtQuick.Controls2.15Rectangle{width:600height:200propertyi

一、效果

 

二、代码

import QtQuick 2.0
import QtQuick.Controls 2.15Rectangle {width: 600height: 200property int recWidth: 250Rectangle {id: innnerRecwidth: recWidthheight: 50anchors.centerIn: parentcolor: "beige"// 子元素超出该项目的范围时,将被裁减clip: trueText {id: textInfoanchors.verticalCenter: parent.verticalCenterfont.pixelSize: 20text: qsTr("进入环岛图标,右侧通行地区的逆时针环岛")Component.onCompleted: animScroll.running = true}// 顺序动画SequentialAnimation {id: animScroll// 循环次数:极大的loops: Animation.InfinitePropertyAnimation {target: textInfoproperty: "x"from: 0to: -(textInfo.width)duration: (textInfo.width) * 30}PropertyAnimation {target: textInfoproperty: "x"from: recWidthto: 0duration: recWidth * 30}}}Button {anchors.top: innnerRec.bottomanchors.topMargin: 10anchors.horizontalCenter: parent.horizontalCentertext: "stop"onClicked: {text === "start" ? text = "stop" : text = "start"}onTextChanged: text === "stop" ? animScroll.running = true : animScroll.running = false}
}

三、注意


推荐阅读
author-avatar
想想以前哦
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有