本页内容

Shear QML Type

提供了一种对项目进行剪切的方法。更多内容...

Import Statement: import QtQuick
Since: Qt 6.9

属性

详细说明

“剪切”类型提供了一种通过二维剪切矩阵(有时也称为倾斜变换)对Item 进行变换的方法。

Rectangle {
    width: 100; height: 100
    color: "blue"
    transform: Shear {
        xFactor: 1.0
    }
}

这会沿 x 轴将项目按1.0 的比例进行剪切,而沿 y 轴保持不变。每个点P 会被位移xFactor(P.y - origin.y) (即到origin 的带符号垂直距离乘以xFactor )。设置yFactor 则会沿 y 轴对项目进行剪切,且位移量与水平距离成正比。

沿x轴剪切的蓝色矩形变成一个平行四边形

由于默认原点位于(0, 0) ,因此元素的顶部保持不变,而底部则向右偏移了100像素(相当于该元素的高度)。

此代码等同于以下内容:

Rectangle {
    width: 100; height: 100
    color: "blue"
    transform: Shear {
        xAngle: 45.0
    }
}

注意:如果 同时设置了xFactor/yFactor 和xAngle/yAngle ,则将采用两个偏移量的总和。

属性文档

origin group

origin.x : real

origin.y : real

变换的原点(即当项目其余部分发生剪切时,相对于父级保持固定的点)。

默认情况下,原点为(0, 0) 。

xAngle : real

沿x轴对对象坐标系进行剪切的夹角(单位为度)。这相当于将xFactor 设置为tan(xAngle) 。

默认值为0.0 。

另请参阅 xFactor 。

xFactor : real

沿 x 轴对该项坐标系进行剪切的倍数。每个点P 的位移量为xFactor(P.y - origin.y)

这对应于QTransform::shear()中的sh 参数,以及调用PlanarTransform::fromShear()时的xShear 参数。

默认值为0.0 。

另请参阅 xAngle 。

yAngle : real

沿 y 轴对该对象坐标系进行剪切的角度(单位为度)。这相当于将 `yFactor ` 设置为 `tan(yAngle)`。

默认值为0.0 。

另请参阅 yFactor 。

yFactor : real

沿 y 轴剪切该项目坐标系的比例因子。沿 x 轴剪切该项目坐标系的比例因子。每个点P 的位移量为xFactor(P.y - origin.y)

这对应于QTransform::shear()中的sv 参数,以及调用PlanarTransform::fromShear()时的yShear 参数。

默认值为0.0 。

另请参阅 yAngle 。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.