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. Setting a variable angle for the Transform: Rotation {} element?
Forum Update on Monday, May 27th 2025

Setting a variable angle for the Transform: Rotation {} element?

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 890 Views
  • 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.
  • B Offline
    B Offline
    bruce3141
    wrote on 17 Aug 2013, 15:46 last edited by
    #1

    I am running Qt 5.1 and QtQuick 2.0 on a Mac with OS-X 10.8.4.

    I am having trouble setting a variable angle for the Transform: Rotation {} element, like this:
    @transform: Rotation {
    axis { x: 0; y: 1; z: 0 }
    angle: PathView.angle
    }@

    where PathView.angle varies for each image element of my model. I followed the "code here for a cover-flow style container":http://developer.nokia.com/Community/Wiki/Building_a_CoverFlow_component_with_QML but that example doesn't work either(!) - at least in terms of setting the rectangle angles correctly.

    To help troubleshoot this issue, I have put together a simple QML code to illustrate the issue. See Case 3 in the comments, that is the case I would like to get to work except that this case gives an error (once for each image container):

    Unable to assign [undefined] to double

    because a variable angle doesn't seem to work with Transform: Rotation {}: Why?

    Cases 1 & 2 are just test cases to help explore the issue, these work but are not what I want.

    Note that Case 1 would be fine except that the rotation axis is about z (that must be the default) but what I really want is the rotation axis to be defined about y. That is what brings me to using the Transform: Rotation {} element (to change the rotation axis).

    Any help or comments appreciated! Thanks.

    Code:

    @import QtQuick 2.0

    Rectangle {
    id: mainRect
    width: 1024; height: 300

    // Flow View:
    Rectangle {
        width: parent.width; height: parent.height
        color: "gray"
    
        PathView {
            id: myPV
            delegate: pathdelegate
            anchors.fill: parent
            model: 11 // provide a range of indices
    
            Keys.onLeftPressed: if (!moving && interactive) incrementCurrentIndex()
            Keys.onRightPressed: if (!moving && interactive) decrementCurrentIndex()
    
            preferredHighlightBegin: 0.5
            preferredHighlightEnd: 0.5
            focus: true
            interactive: true
    
            path: Path {
                id: pathElement
                startX: 0; startY: myPV.height / 2
                PathAttribute { name: "z"; value: 0 }
                PathAttribute { name: "angle"; value: 60 }
                PathAttribute { name: "scale"; value: 0.5 }
                PathLine { x: myPV.width / 2; y: myPV.height / 2;  }
                PathAttribute { name: "z"; value: 100 }
                PathAttribute { name: "angle"; value: 0 }
                PathAttribute { name: "scale"; value: 1.0 }
                PathLine { x: myPV.width; y: myPV.height / 2; }
                PathAttribute { name: "z"; value: 0 }
                PathAttribute { name: "angle"; value: -60 }
                PathAttribute { name: "scale"; value: 0.5 }
            }
        }
    
        // Delegate Component:
        Component {
            id: pathdelegate
            Rectangle {
                id: rect
                width: 256; height: 256
                z: PathView.z
                scale: PathView.scale
                color: "black"
                border.color: "white"
                border.width: 3
    
                // Case 1: This works:
                rotation: PathView.angle
    
                 //Case 2: This works:
                 //transform: Rotation {
                 //   axis { x: 0; y: 1; z: 0 }
                 //   angle: 60
                 //}
    
                // Case 3: This is the case that I need to work:
                // This DOES NOT work:
                // transform: Rotation {
                //    axis { x: 0; y: 1; z: 0 }
                //    angle: PathView.angle
                //}
            }
    
        } // End: Delegate Component
    
    } // End: Flow View:
    

    } // End: mainRect@

    1 Reply Last reply
    0

    1/1

    17 Aug 2013, 15:46

    • Login

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