このページでは

PathRectangle QML Type

角を丸くすることもできる長方形を定義します。詳細...

Import Statement: import QtQuick
Since: QtQuick 6.8

プロパティ

詳細な説明

PathRectangle を使用すると、角を丸くしたり面取りしたりすることも可能で、矩形を簡単に指定できます。この API は、Rectangle アイテムの API に対応しています。

角が面取りされた長方形

    Shape {
        id: rectangleShape
        width: 200
        height: 150
        anchors.centerIn: parent
        preferredRendererType: Shape.CurveRenderer

        ShapePath {
            fillColor: "#3ad23c"

            PathRectangle {
                width: rectangleShape.width
                height: rectangleShape.height
                topLeftRadius: 30
                bottomRightRadius: 30
                bevel: true
            }
        }
    }

関連項目: Path 、PathLine 、PathQuad 、PathCubic 、PathArc 、PathAngleArc 、PathCurve 、およびPathSvg 。

プロパティのドキュメント

bevel : bool [since 6.10]

このプロパティは、矩形の角を面取りするかどうかを定義します。

これをfalse に設定すると、個々のradius プロパティの値に応じて、角がシャープになるか丸くなるかが決まります。

このプロパティは、個々のbevelプロパティによって上書きされる場合があります。

    Shape {
        id: rectangleShape
        width: 200
        height: 150
        anchors.centerIn: parent
        preferredRendererType: Shape.CurveRenderer

        ShapePath {
            fillColor: "#3ad23c"

            PathRectangle {
                width: rectangleShape.width
                height: rectangleShape.height
                topLeftRadius: 30
                bottomRightRadius: 30
                bevel: true
            }
        }
    }

左上と右下の角が面取りされた長方形

このプロパティは Qt 6.10 で導入されました。

topLeftBevel 、topRightBevel 、bottomLeftBevel 、およびbottomRightBevelも参照してください 。

bottomLeftBevel : bool

bottomRightBevel : bool

topLeftBevel : bool

topRightBevel : bool

設定すると、これらのプロパティは個々の角のベベルを定義します。これらをfalse に設定すると、個々のradius プロパティの値に応じて、角がシャープになるか丸くなるかのいずれかになります。これらをtrue に設定すると、角にベベルが適用されます。設定されていない場合は、代わりにbevel の値が使用されます。

これらのプロパティは、デフォルトでは設定されていません。undefined を割り当てることで、設定されていない状態に戻すことができます。

次の例では、bottomRightBevel が true に設定されています:

    Shape {
        id: rectangleShape
        width: 200
        height: 150
        anchors.centerIn: parent
        preferredRendererType: Shape.CurveRenderer

        ShapePath {
            strokeColor: "black"
            strokeWidth: 4
            joinStyle: ShapePath.MiterJoin

            PathRectangle {
                width: rectangleShape.width
                height: rectangleShape.height
                radius: 10
                topLeftRadius: 0
                bottomRightBevel: true
            }
        }
    }

3つの角が丸く、1つの角が面取りされた長方形の輪郭

「bevel」も参照してください 。

bottomLeftRadius : real

bottomRightRadius : real

topLeftRadius : real

topRightRadius : real

これらのプロパティを設定すると、個々の角の半径を定義できます。値を 0 に設定するとその角は鋭角になり、正の値を設定すると丸みを帯びた角になります。設定されていない場合は、代わりに `radius ` の値が使用されます。

これらのプロパティはデフォルトでは設定されていません。undefined を割り当てることで、設定されていない状態に戻すことができます。

次の例では、radius は10 に、topLeftRadius は0 に設定されています:

    Shape {
        id: rectangleShape
        width: 200
        height: 150
        anchors.centerIn: parent
        preferredRendererType: Shape.CurveRenderer

        ShapePath {
            strokeColor: "black"
            strokeWidth: 4
            joinStyle: ShapePath.MiterJoin

            PathRectangle {
                width: rectangleShape.width
                height: rectangleShape.height
                radius: 10
                topLeftRadius: 0
                bottomRightBevel: true
            }
        }
    }

3つの角が丸く、1つの角が面取りされた長方形の輪郭

「radius」も参照してください 。

height : real

width : real

長方形の幅と高さを指定します。

x およびyも参照してください 。

radius : real

このプロパティは、角丸長方形を定義するために使用される角の半径を指定します。

radius が正の値の場合、矩形パスは角丸矩形として定義され、そうでない場合は通常の矩形として定義されます。

このプロパティは、個々の角の半径プロパティによって上書きされる場合があります。

デフォルト値は `0` です。

関連項目: topLeftRadius 、topRightRadius 、bottomLeftRadius 、およびbottomRightRadius 。

relativeX : real

relativeY : real

パスの始点を基準として、矩形の左上隅を定義します。

1つの軸に対して相対位置と絶対位置の両方が指定されている場合、相対位置が使用されます。

相対位置と絶対位置を混在させることも可能です。たとえば、x 軸を相対位置、y 軸を絶対位置に設定することは有効です。

x およびyも参照してください 。

strokeAdjustment : real

このプロパティは、矩形の座標に対するストローク幅の調整を定義します。

ストロークが有効になっているShapePath で使用する場合、実際にストロークされる矩形は、デフォルトでは定義された矩形の各辺からストローク幅の半分分だけはみ出します。これは、パスがストロークの中間線を定義しており、QPainter およびSVGのレンダリングに準拠しているため、想定される動作です。

一方、境界線付きのRectangle アイテムのように、定義された矩形をストロークされた矩形の外縁にしたい場合は、`strokeAdjustment`をストローク幅に設定できます。これにより、事実上、すべての辺がストローク幅の半分だけ内側にシフトされます。以下の例のように:

ShapePath {
    id: myRec
    fillColor: "white"
    strokeColor: "black"
    strokeWidth: 16
    joinStyle: ShapePath.MiterJoin

    PathRectangle { x: 10; y: 10; width: 200; height: 100; strokeAdjustment: myRec.strokeWidth }
}

x : real

y : real

長方形の左上隅を指定します。

その角が丸くされていない限り、ここがパスの始点および終点にもなります。

「 relativeX 」および「relativeY 」も参照してください 。

© 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.