Почему выдаёт ошибку в QML значении parent

Почему в строчках "target: parent" выдаёт ошибку "ReferenceError: parent is not defined"?

import QtQuick 2.15
import QtQuick.Window 2.15

Window {
    id: root

    visible: true

    width: 1280
    height: 720

    title: qsTr("Hello World")

    Rectangle {
        id: rect

        width: 65
        height: 65

        // x: parent.width / 2 - width / 2
        y: parent.height / 2 - height / 2

        color: "black"

        PropertyAnimation {
            id: animationRight

            target: parent
            property: "x"
            to: root.width - rect.width
            duration: 1000
        }

        PropertyAnimation {
            id: animationLeft

            target: parent
            property: "x"
            to: 0
            duration: 1000
        }

        MouseArea {
            id: mouseArea

            anchors.fill: parent

            onClicked: {
                if (parent.x == 0) {
                    animationRight.start()
                } else {
                    animationLeft.start()
                }
            }
        }
    }
}

Ответы (0 шт):