Thanks scgrant327 ! I corrected rect1.height. And semicolon between to and easing.type will be wrong and wont compile.
Is there any option for compiler to show undefined properties (like rect1.heigh)?
Now it compile and works but it seems to decease "y" instead grow. So animation is upwards screen instead downwards screen. It is strange because I clearly typed animation from y=0 to y = baza.height - rect1.height which later mean something like y = 1100 - 100 so I don't suspect negative value for to:
Now corrected code is as follow:
import QtQuick 2.5
import QtQuick.Window 2.2
import QtQuick.Controls 1.4
Window {
visible: true
title: qsTr("Hello World")
visibility: Window.Maximized
Rectangle
{
id: baza
x: 0
y: 0
width: parent.width
height: parent.height
Text
{
id: log1
anchors.centerIn: parent
text: "Type something..."
}
Rectangle
{
id: rect1
x: 100
y: 100
width: 9
height: 100
radius: width / 2
color: "blue"
function calculateY() {
log1.text = "baza.height: %1, baza.height - height: %2".arg(baza.height).arg(baza.height - this.height);
return baza.height - this.height; // == 1047
}
SequentialAnimation on y {
loops: Animation.Infinite
running: true
// NumberAnimation { from: 0; to: 1047; easing.type: Easing.OutExpo; duration: 3000 } // \ that works as expected
// NumberAnimation { from: 1047; to: 0; easing.type: Easing.OutExpo; duration: 3000 } // /
NumberAnimation { from: 0; to: rect1.calculateY(); easing.type: Easing.OutExpo; duration: 3000 } // \ not works == animated upwards instead downwards
NumberAnimation { from: rect1.calculateY(); to: 0; easing.type: Easing.OutExpo; duration: 3000 } // /
}
}
MouseArea
{
anchors.fill: baza
onClicked: { Qt.quit(); }
}
}
}
import QtQuick 2.5
import QtQuick.Window 2.2
import QtQuick.Controls 1.4
Window {
visible: true
title: qsTr("Hello World")
visibility: Window.Maximized
Rectangle
{
id: baza
x: 0
y: 0
width: parent.width
height: parent.height
Text
{
id: log1
anchors.centerIn: parent
text: "Type something..."
}
Rectangle
{
id: rect1
x: 100
y: 100
width: 9
height: 100
radius: width / 2
color: "blue"
function calculateY() {
log1.text = "baza.height: %1, baza.height - height: %2".arg(baza.height).arg(baza.height - this.height);
return baza.height - this.height; // == 1047
}
SequentialAnimation on y {
loops: Animation.Infinite
running: true
// NumberAnimation { from: 0; to: 1047; easing.type: Easing.OutExpo; duration: 3000 } // \ that works as expected
// NumberAnimation { from: 1047; to: 0; easing.type: Easing.OutExpo; duration: 3000 } // /
NumberAnimation { from: 0; to: rect1.calculateY(); easing.type: Easing.OutExpo; duration: 3000 } // \ not works == animated upwards instead downwards
NumberAnimation { from: rect1.calculateY(); to: 0; easing.type: Easing.OutExpo; duration: 3000 } // /
}
}
MouseArea
{
anchors.fill: baza
onClicked: { Qt.quit(); }
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks