Reputation: 422
I want to set my fullscreen app on one of my screens, so I have to set its height,width, x,y and so on. However I found the animation doesn't work.
I ever thought this caused by I set it on one targeted screen, so I create a test code, here I hard code the x,y, but the animation still doesn't work, can someone tell me why?
My test code is as following:
import QtQuick 2.6
import QtQuick.Window 2.2
Window {
visible: true
title: qsTr("Hello World")
flags: Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint
opacity: 0.6
id: root
MouseArea {
anchors.fill: parent
onClicked: {
//Qt.quit();
}
}
Component.onCompleted: {
root.x = 0;
root.y = 0;
root.width = Screen.width;
root.height = Screen.height;
initWindow.start();
}
PropertyAnimation {
id: initWindow
target: root
from: 0
to: Screen.height
duration: 2000
easing.type: Easing.InOutQuad
onRunningChanged: {
if(!initWindow.running && root.visibility != Window.Hidden){
console.log("here is initWindow animation.")
}
}
}
}
Upvotes: 0
Views: 1103
Reputation: 13711
Because you do not animate anything. You need to specify a target.
Just a wild guess, but you probably want to animate the height?
Window {
id: root
visible: true
title: qsTr("Hello World")
// opacity: 0.6 // Does not work for me
// I want to have the frames and stuff for an example.
MouseArea {
anchors.fill: parent
onClicked: {
//Qt.quit();
}
}
Component.onCompleted: {
root.x = 0;
root.y = 0;
root.width = 1200;
root.height = 800;
}
Behavior on height { // Starts the Animation with the set target, once the height is set to be changed
NumberAnimation {
id: initWindow
duration: 200000
}
}
}
Or to stay closer to your code:
Window {
id: root
visible: true
title: qsTr("Hello World")
MouseArea {
anchors.fill: parent
onClicked: {
Qt.quit();
}
}
Component.onCompleted: {
root.x = 0;
root.y = 0;
root.width = Screen.width;
initWindow.start();
}
PropertyAnimation {
id: initWindow
target: root
from: 0
to: Screen.height
property: 'height' // You need to declare which property should change.
duration: 2000
easing.type: Easing.InOutQuad
}
}
See the comments, for what I did. And I striped your code of some stuff unnecessary for an example.
Upvotes: 1