Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Apply rotation to an item multiple items



  • Hi ,

    I want to apply 'rotation' property to an image in different angles to give different view everytime. So, how do I apply rotation 'n' times to an image.

        transform: Rotation { origin.x: image.width/2; origin.y: image.height/2; angle: 20}
        transform: Rotation { origin.x: image.width/2; origin.y: image.height/2; angle: -30}
    

    If i try multiple times to apply the property in qml, it gives error of "Duplicate property binding (M10)".



  • Hi, don't define 'transform' 2 times, just change 'angle' property

    transform: Rotation {id:myR origin.x: image.width/2; origin.y: image.height/2; angle: 20}
    ..
    myR.angle = -30



  • Timer{
            onTriggered: theRotation.angle = Math.random()*360
            interval: 1000//1s
            running: true
            repeat: true
    
        }
    
        Image{
            id:img
            anchors.centerIn: parent
            height: sourceSize.height
            width: sourceSize.width
            source:"GUI/img/icon5.png"
            transform: Rotation{
                 id: theRotation
                 origin.x: img.width/2; origin.y: img.height/2; angle: 20
                Behavior on angle {
                    NumberAnimation{
                        duration: 200
                    }
                }
            }
        }
    


  • @LeLev
    hey, I tried this but it throws error of "invalid property name".



  • @Ronak5 hi, as we solved your issue you can mark this as solved


Log in to reply