NumberAnimation can't refer to its parent SequentalAnimation



  • My code:

    import QtQuick 2.5
    import QtQuick.Window 2.2
    
    Window {
        visible: true
        width: 640
        height: 480
        property double angle: 0
        
        SequentialAnimation on angle {
            property int myDuration: 3000 // const
            NumberAnimation {
                from: -30.0
                to: 30.0
                duration: parent.myDuration
                easing.type: Easing.InOutSine
            }
        }
    }
    

    I get this error on the "parent.myDuration" line:

    ReferenceError: parent is not defined

    Any ideas?


  • Qt Champions 2016

    Tried referencing by id?



  • Hi! The parent property is the visual parent of the basic visual QML type Item and must not be confused with the parent QObject in a QObject tree. The Animation QML type is not derived from Item (because it has no visual representation) and thus does not have a visual parent / no parent property.



  • @kshegunov :
    Sure, that works, but I was wondering why it doesn't work with parent as well.

    @Wieland :
    Ok, thanks!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.