Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] NumberAnimation on <property alias> doesn't work.
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] NumberAnimation on <property alias> doesn't work.

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.7k Views 1 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.
  • T Offline
    T Offline
    trusktr
    wrote on last edited by
    #1

    I'm trying to animate an aliased property:

    @
    property alias blah: cloudRotation.angle; // assume this line is correct;

        NumberAnimation on blah {
            id: cloudRotationAnimation;
            to: 0;
            duration: 10000;
            loops: Animation.Infinite;
        }
    

    @

    It complains that

    @
    Cannot assign to non-existent property "blah"
    NumberAnimation on blah {
    @

    But if I try it on a normal property, it works fine:

    @
    NumberAnimation on x {
    id: cloudRotationAnimation;
    to: 0;
    duration: 10000;
    loops: Animation.Infinite;
    }
    @

    Can property aliases be used like that? If not, how can I get around it?

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      You can do on alias. Alias will be ready only when the component is completely initialized. If you put the animation directly, it is not completely ready. Check the following piece of code.

      @ Rectangle {
      id : rec
      width: 100; height: 100
      color: "red"

          property alias b : rec.x
          PropertyAnimation { id: animation;target: rec; property: "b"; to: 30; duration: 500 }
          MouseArea {
              anchors.fill: parent
              onClicked: {
                    console.log("I am here")
                    animation.running = true;
              }
          }
      }
      

      @

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • T Offline
        T Offline
        trusktr
        wrote on last edited by
        #3

        Sweet. That's good to know. Thanks Dheerendra. Is there an onLoad event I could use or something? If so, how'd that work?

        EDIT 11 min later:
        Nevermind, I found Component.onCompleted.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          trusktr
          wrote on last edited by
          #4

          Here's my code:
          @
          import QtQuick 2.0;
          import Qt3D 2.0;
          import Qt3D.Shapes 2.0;

          Viewport {
          width: 480; height: 640;

          Sphere {
              radius: 1.5;
              levelOfDetail: 6;
              axis: Qt.YAxis;
              effect: Effect {
                  texture: "qrc:/img/earth_day.jpg";
              }
          }
          Sphere {
              radius: 1.535;
              levelOfDetail: 6;
              axis: Qt.YAxis;
              effect: Effect {
                  blending: true;
                  color: Qt.rgba(255,255,255,0.6);
                  texture: "qrc:/img/earth_clouds.jpg";
              }
              transform: Rotation3D {
                  id: cloudRotation;
                  angle: 0;
                  axis: Qt.vector3d(0, 1, 0);
              }
              property alias blah: cloudRotation.angle;
          
              NumberAnimation {
                  id: cloudRotationAnimation;
                  running: false;
                  target: parent;
                  property: "blah";
                  //from: 0;
                  to: 360;
                  duration: 10000;
                  loops: Animation.Infinite;
              }
              Component.onCompleted: {
                  cloudRotationAnimation.running = true;
                  console.log("i am here"); // this works
              }
          }
          

          }
          @

          Basically what I'm trying to do is rotate the clouds. When I do
          @
          cloudRotationAnimation.running = true;
          @
          nothing happens. Why might that be?

          EDIT 20 min later:
          Fixed it! I had to change
          @
          cloudRotationAnimation.running = true;
          @
          to
          @
          cloudRotationAnimation.start();
          @

          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