Reputation: 35
I have a text element in my window and I would like it be blink or appear and disappear for every few seconds or milli seconds.
My code is:
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
}
}
Upvotes: 3
Views: 1553
Reputation: 38082
Another solution using OpacityAnimator
:
import QtQuick 2.6
import QtQuick.Window 2.2
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Text {
anchors.centerIn: parent
id: my_text
text: "Hello"
font.pixelSize: 30
OpacityAnimator {
target: my_text;
from: 0;
to: 1;
duration: 400;
loops: Animation.Infinite;
running: true;
easing {
type: Easing.InOutExpo;
}
}
}
}
Upvotes: 1
Reputation: 244162
The task is easily solved with a 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
}
}
Upvotes: 5