新手一枚,求助 QML中 Text 滚动输出

xuzhang8668 2014-12-12 01:40:09
Text 一行宽度有限,字数太长,不想换行或者省略,想在一行滚动输出所有文字,该是如何设置~~
...全文
625 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
Rectangle{
        id:rectText
        x:100;y:200
        width: 300;height: 20
        border.color: "blue"
        border.width: 2
        clip:true

        Text{
            id:contentTextId

            text:"dsfagdfsddddddnvhfghddddsdddddfgjhkmukhdddjhjhggdddddfgdfhdfyjfugkybnsfgbsrgrt"
            font.pointSize: 10

            NumberAnimation {
                id:animText
                target: contentTextId
                property: "x"
                duration: 15000
                to:(contentTextId.text.length - rectText.width )
                running: false
                easing.type: Easing.OutCubic
            }

        }

        MouseArea{
            anchors.fill: parent
            onClicked: {
                animText.start()
            }
        }
    }
你点击那个矩形框就可以看到text文本的滚动显示,当然你可以根据需要改变触发时机
zck0911 2015-05-12
  • 打赏
  • 举报
回复
类似于这样 Text { id: text1 text:textForShow color:textColor font.family: fontFamily font.pixelSize: fontPixelSize PropertyAnimation on x { id:animation running: animationRunning from:405 to:(0-text1.text.length*text1.font.pixelSize)+300; duration: animationDuration/3 // duration: 15*1000 loops:1 onStopped:{ animation.start() } } }

16,211

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧