Advertisement
stuppid_bot

Untitled

Feb 7th, 2016
1,110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 1.01 KB | None | 0 0
  1. import QtQuick 2.5
  2. // import QtQuick.Window 2.2
  3. // import "assets" as Assets
  4. // import "assets/scripts/utils.js" as Utils
  5.  
  6. Rectangle {
  7.   id: root
  8.   visible: true
  9.   width: 200
  10.   height: 200
  11.   // radius: width / 2
  12.   state: "red"
  13.  
  14.   states: [
  15.     State {
  16.       name: "red"
  17.       PropertyChanges {
  18.         target: root
  19.         color: "red"
  20.       }
  21.     },
  22.  
  23.     State {
  24.       name: "green"
  25.       PropertyChanges {
  26.         target: root
  27.         color: "green"
  28.       }
  29.     },
  30.  
  31.     State {
  32.       name: "blue"
  33.       PropertyChanges {
  34.         target: root
  35.         color: "blue"
  36.       }
  37.     }
  38.   ]
  39.  
  40.   transitions: [
  41.     Transition {
  42.       ColorAnimation {
  43.         duration: 500
  44.       }
  45.     }
  46.   ]
  47.  
  48.   Timer {
  49.     id: timer
  50.     interval: 3000
  51.     repeat: true
  52.     property int index: 0
  53.  
  54.     onTriggered: {
  55.       ++index
  56.       if (index == root.states.length) {
  57.         index = 0
  58.       }
  59.       root.state = root.states[index].name
  60.     }
  61.   }
  62.  
  63.   Component.onCompleted: {
  64.     timer.start()
  65.   }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement