Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. NumberAnimation can't refer to its parent SequentalAnimation
Forum Updated to NodeBB v4.3 + New Features

NumberAnimation can't refer to its parent SequentalAnimation

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qml parent
4 Posts 3 Posters 967 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Stefan Monov76S Offline
    Stefan Monov76S Offline
    Stefan Monov76
    wrote on last edited by
    #1

    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?

    kshegunovK 1 Reply Last reply
    0
    • Stefan Monov76S Stefan Monov76

      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?

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      Tried referencing by id?

      Read and abide by the Qt Code of Conduct

      Stefan Monov76S 1 Reply Last reply
      1
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        1
        • kshegunovK kshegunov

          Tried referencing by id?

          Stefan Monov76S Offline
          Stefan Monov76S Offline
          Stefan Monov76
          wrote on last edited by
          #4

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

          @Wieland :
          Ok, thanks!

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved