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

Transform only parent Item



  • How to transform only parent item without affection on children?

    For example

    @
    Rectangle {
    id: panel
    width: 400
    height: 200
    x: parent.right-width/2
    color: "white"
    anchors.bottom: parent.bottom
    clip: true

            transform: Rotation {
                origin.x: page.width; origin.y: page.height; axis {x:0; y:0; z:1} angle:0
                NumberAnimation on angle  {
                    from: 0; to: 90;
                    duration: 3000;
                    loops: Animation.Infinite
                }
            }
    
            Image {
                id: image1
                x: 16
                y: 27
                source: "images/qt.svg"
            }
        }
    

    @

    I don't want rotate Qt logo, just stick in "World Position" and hide when parent bounding box live this coordinates.



  • Can you make the rectangle and the image sibling instead of parent-child? Then, the transform to the rect doesn't affect to the image.



  • [quote author="moo1" date="1299195108"]Can you make the rectangle and the image sibling instead of parent-child? Then, the transform to the rect doesn't affect to the image.[/quote]

    No, I need "clip: true".


  • Moderators

    You could place the Image at the appropriate offset on a transparent rectangle (or perhaps just a plain Item element) which was anchored at the exact point of panel's rotation, then set the transparent container's rotation to the opposite of pane's (container.rotation: -panel.rotation).



  • [quote author="mlong" date="1299275809"]You could place the Image at the appropriate offset on a transparent rectangle (or perhaps just a plain Item element) which was anchored at the exact point of panel's rotation, then set the transparent container's rotation to the opposite of pane's (container.rotation: -panel.rotation).[/quote]

    Thanks, it's working
    @
    import QtQuick 1.0

    Rectangle {
    id: mainRec
    width: 600
    height: 600
    color: "grey"

    Rectangle {
        id: page
        anchors.centerIn: parent
        color: "black"
        width: 200
        height: 400
        clip: true
    
        Rectangle {
            id: pane
            width: 400
            height: 400
            x: parent.right-width/2
            color: "white"
            clip: true
    
            anchors.bottom: parent.bottom
            transformOrigin: Item.Bottom
    
            NumberAnimation on rotation {
                from: 0; to: 90
                duration: 3000
                loops: Animation.Infinite
            }
    
            Item {
                id: container
                width: pane.width
                height: pane.height
                anchors.bottom: parent.bottom
                transformOrigin: Item.Bottom
                rotation: -parent.rotation
    
                Image {
                    id: image1
                    x: 16
                    y: 27
                    source: "images/qt.svg"
                }
            }
        }
    }
    

    }

    @



  • But there other problem, how to prevent from moving "container", if parent draggable.


Log in to reply