如何使QT文本每隔几毫秒重新出现(闪烁)

如何使QT文本每隔几毫秒重新出现(闪烁),qt,text,timer,qml,qt5,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.pixelSi

我的窗口中有一个文本元素,我希望它每隔几秒或几毫秒闪烁或出现并消失

我的代码是:

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
    }
}

这项任务很容易用简单的方法解决


这项任务很容易用简单的方法解决


另一种使用
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;
            }
        }
    }
}

另一种使用
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;
            }
        }
    }
}

为什么要使用
不透明度
而不是
可见
?IMHO
visible=!可见
更易于阅读。使用不透明度是否有性能优势?为什么使用
不透明度
而不是
可见
?IMHO
visible=!可见
更易于阅读。使用不透明度是否有性能优势?