Lea*_*ath 3 qt text timer qml qt5
我的窗口中有一个文本元素,我希望它每隔几秒或几毫秒闪烁或出现和消失。
我的代码是:
import QtQuick 2.6
import QtQuick.Window 2.2
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Text {
id: my_text
text: "Hello"
font.pixelSize: 30
}
}
Run Code Online (Sandbox Code Playgroud)
该任务很容易解决Timer。
import QtQuick 2.6
import QtQuick.Window 2.2
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Text {
id: my_text
font.pixelSize: 30
text: "Hello"
}
Timer{
id: timer
interval: 1000
running: true
repeat: true
onTriggered: my_text.opacity = my_text.opacity === 0 ? 1 : 0
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1416 次 |
| 最近记录: |