Skip to content

Instantly share code, notes, and snippets.

@zethon
Last active November 23, 2023 01:34
Show Gist options
  • Save zethon/1bb9b9bd9f364a93fa0b089e2342ff38 to your computer and use it in GitHub Desktop.
Save zethon/1bb9b9bd9f364a93fa0b089e2342ff38 to your computer and use it in GitHub Desktop.
QML Popup Transition
import QtQuick.Window 2.2
// import QtQuick.Controls 2.12
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import QtGraphicalEffects 1.0
import QtQuick.Controls.Material 2.3
ApplicationWindow {
id: window
width: 400
height: 400
visible: true
Button {
text: "Open"
onClicked: globalPopUpDialog.open()
}
Popup {
id: globalPopUpDialog
property var title : "Unknown title"
property var description : "Unknown details"
property var type : "info"
parent: Overlay.overlay
modal: true
focus: true
width: parent.width * 0.618
height: 200
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
dim: true
x: (parent.width / 2) - (width / 2)
enter: Transition
{
NumberAnimation
{
property: "y";
from: window.height
to: window.height - globalPopUpDialog.height
duration: 125
}
}
exit: Transition
{
NumberAnimation
{
property: "y";
from: window.height - globalPopUpDialog.height
to: window.height
duration: 125
}
}
contentItem : Pane
{
id: pane
Material.elevation: 16
ColumnLayout
{
anchors.fill: parent
anchors.margins: 10
Text
{
text: qsTr("Title")
font.bold: true
}
Text
{
text: qsTr("This is the description")
font.weight: Font.Light
}
Button
{
text: "click me!";
onClicked:
{
globalPopUpDialog.close();
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment