Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Is it possible in QML to smoothly open in a new window



  • Good afternoon.
    I read that you I can make an animated transition between the States of one window. But is it possible to make a smooth opening of another window, for example, to the window smoothly left from some side?



  • import QtQuick 2.4
    import QtQuick.Window 2.0
    import QtQuick.Controls 2.5
     
    Window {
        id: window
        width: 400
        height: 400
        visible: true
     
        Loader {
            id: loader
            anchors.fill: parent
     
            onSourceChanged: animation.running = true
     
            NumberAnimation {
                id: animation
                target: loader.item
                property: "x"
                from: -width
                to: 0
                duration: 1000
                easing.type: Easing.InExpo
            }
        }
     
        Button {
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 5
     
            text: qsTr("Click me")
     
            onClicked: {
                loader.source = "MyRectangle.qml"
            }
        }
    

Log in to reply