Skip to content

Instantly share code, notes, and snippets.

@t-artikov
Created June 29, 2018 09:33
Show Gist options
  • Save t-artikov/87715f02e1ca2bd492ccbd9255180aff to your computer and use it in GitHub Desktop.
Save t-artikov/87715f02e1ca2bd492ccbd9255180aff to your computer and use it in GitHub Desktop.
import QtQuick 2.0
Rectangle {
id: root
property QtObject window
implicitWidth: 300
implicitHeight: 150
color: Qt.rgba(0.5, 0, 0.5, 1)
Item {
NumberAnimation on rotation {
id: animation
running: true
from: 0
to: 360
loops: Animation.Infinite
duration: 1000
}
}
Rectangle {
id: d
property bool tick
property real t: Date.now()
anchors.fill: parent
anchors.margins: 20
color: tick ? Qt.rgba(1, 0, 0, 1) : Qt.rgba(0, 0, 1, 1)
}
Connections {
target: root.window
onAfterAnimating: {
d.tick = !d.tick;
var newT = Date.now();
var dt = newT - d.t;
if(dt > 30) print("Drop!", dt);
d.t = newT;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment