Reputation: 1021
My code is here:
MyPopup.qml
:
import QtQuick 2.0
import QtQuick.Window 2.3
import QtQuick.Controls 2.2
Popup {
id: popup
width: 250
height: 250
closePolicy: Popup.NoAutoClose
y: -300
background: Rectangle {
anchors.fill: parent
color: '#3f3f3f'
opacity: 15
Text {
text: 'HELLO WORLD!'
color: 'white'
font.pointSize: 20
anchors.centerIn: parent
}
Button {
anchors.bottom: parent.bottom
text: 'Close Popup'
onClicked: popup.close()
}
}
enter: Transition {
NumberAnimation {
target: parent
property: 'y'
to: (Screen.height / 2) - (height / 2)
duration: 400
running: true
}
}
exit: Transition {
NumberAnimation {
target: parent
property: 'y'
to: -((Screen.height / 2) - (height / 2))
duration: 400
running: true
}
}
}
I put a button into main.qml
. When I click that button, popup.open()
is running. I put a button into MyPopup.qml
, when I click that button, popup.close()
is running. When I clik the buttons, my app is freezing and closing.
I get this warnings:
qrc:/MyPopup.qml:31:5: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.
qrc:/MyPopup.qml:41:5: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.
Upvotes: 4
Views: 1480
Reputation: 575
In documentation, two examples are given and none of them have running
property instantiated. Example of enter
property:
Popup {
enter: Transition {
NumberAnimation { property: "opacity"; from: 0.0; to: 1.0 }
}
}
And for exit
property:
Popup {
exit: Transition {
NumberAnimation { property: "opacity"; from: 1.0; to: 0.0 }
}
}
I tried your code without running: true
line and it worked. So when popup.open()
or popup.exit()
are called, the transitions just run.
Upvotes: 2