2017-10-17 2 views

답변

3

작업은 쉽게 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 
    } 
} 
+0

왜 대신'visible'의 opacity''사용하고 있습니까? IMHO'visible =! visible'은 읽기 쉽습니다. 불투명도를 사용하면 성능상의 이점이 있습니까? – derM

0

또 다른 해결책은 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; 
      } 
     } 
    } 
} 
관련 문제