[Interest] [noob/qml] anchoring to window vs item

Christian Gagneraud chgans at gmail.com
Sat Aug 25 00:18:49 CEST 2018


Hi there,

I'm trying to create a screen, with 2 vertical side bars, when the
screen is shown, i would like to have a gentle animation where the
side bars looks like they come from the outer sides.
I can achieve this result when my bar item bind to the width property
of the windows, but it doesn't work if it binds to the width of the
'root' item (an intermediate container)
In the code below, "leftBar.width: window.width/8" works as expected,
but none of "leftBar.width: root.width/8", "leftBar.width:
container.width/8" or "leftBar.width: parent.width/8" works, the bar
is not animated.
The problem is certainly simple, but given that i am a noob with Qml...

Does anyone knows what wrong am I doing? Any hint appreciated.

Thanks,
Chris

-----------------------------------------------------------
import QtQuick 2.9
import QtQuick.Window 2.2

Window {
    id: window
    visible: true
    width: 1024
    height: 600
    Item {
        id: root
        anchors.fill: parent
        Item {
            property Item container: root
            id: leftBar
            width: window.width/8 // <=======
            height: container.height
            Rectangle {
                ListView {
                   ...
                }
            }
            PropertyAnimation on x {
                from: -width
                to: 0
                duration: 500
                easing.type: Easing.OutBounce
            }
        }
    }
}
-----------------------------------------------------------



More information about the Interest mailing list