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

Horizontally flipping component changes x position



  • I am attempting to horizontally flip a QML component. I have the below shape:

    enter image description here

    And I am attempting to flip/reflect it horizontally to produce:

    enter image description here

    I can flip the component using Matrix4x4 (see below code) but it also changes the x position. See below image.

    How can I preserve the x position when flipping the component? Ie, how can I keep it in the same place?

    enter image description here

    In the below ignore the blue label. The green line should sit more right, ie, have the same x position as the above.

    enter image description here

    Shape {
        id: annotationHLine;
        anchors.left: annotationShp.right;
        anchors.top: annotationShp.top;
        anchors.topMargin: annotationShp.height * 0.5;
    
        ShapePath {
            strokeWidth: 2;
            strokeColor: "Green";
            fillColor: "transparent";
            startX: -slant; startY: 0;
            PathLine { x: relativeTargetX*0.5; y: 0 }
            PathLine { x: relativeTargetX; y: relativeTargetY }
        }
    
        transform: Matrix4x4 {
          matrix: Qt.matrix4x4(-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
        }
    }
    

  • Moderators

    Maybe try the Rotation API instead? It's simpler.


Log in to reply