Last active
November 23, 2023 01:34
QML Popup Transition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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