In questa pagina

PathRectangle QML Type

Definisce un rettangolo con angoli arrotondati (facoltativi). Altro...

Import Statement: import QtQuick
Since: QtQuick 6.8

Proprietà

Descrizione dettagliata

PathRectangle offre un modo semplice per specificare un rettangolo, con angoli arrotondati o smussati (facoltativamente). L'API corrisponde a quella dell'elemento Rectangle.

Rettangolo con angoli smussati

    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
            }
        }
    }

Vedi anche Path, PathLine, PathQuad, PathCubic, PathArc, PathAngleArc, PathCurve e PathSvg.

Documentazione sulla proprietà

bevel : bool [since 6.10]

Questa proprietà definisce se gli angoli del rettangolo sono smussati.

Impostandola su " false " si ottengono angoli netti o arrotondati, a seconda dei valori delle singole proprietà " radius ".

Questa proprietà può essere sovrascritta dalle singole proprietà di smussatura.

    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
            }
        }
    }

Rettangolo con gli angoli in alto a sinistra e in basso a destra smussati

Questa proprietà è stata introdotta in Qt 6.10.

Vedi anche topLeftBevel, topRightBevel, bottomLeftBevel e bottomRightBevel.

bottomLeftBevel : bool

bottomRightBevel : bool

topLeftBevel : bool

topRightBevel : bool

Se impostate, queste proprietà definiscono le smussature degli angoli singoli. Impostandole su false si ottengono angoli netti o arrotondati, a seconda dei valori delle singole proprietà radius. Impostandole su true si ottengono angoli smussati. Se non sono impostate, viene utilizzato invece il valore di bevel.

Queste proprietà sono disattivate per impostazione predefinita. Assegnare loro il valore undefined per riportarle allo stato disattivato.

Nell’esempio seguente, bottomRightBevel è impostato su 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
            }
        }
    }

Contorno rettangolare con tre angoli arrotondati e un angolo smussato

Vedi anche ` bevel`.

bottomLeftRadius : real

bottomRightRadius : real

topLeftRadius : real

topRightRadius : real

Se impostate, queste proprietà definiscono i raggi degli angoli singoli. Un valore pari a zero indica che l’angolo è acuto, mentre un valore positivo indica che è arrotondato. Se non sono impostate, viene utilizzato invece il valore di ` radius `.

Per impostazione predefinita, queste proprietà non sono impostate. Assegnare loro il valore ` undefined ` per riportarle allo stato non impostato.

Nell'esempio seguente, radius è impostato su 10 e topLeftRadius su 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
            }
        }
    }

Contorno rettangolare con tre angoli arrotondati e un angolo smussato

Vedi anche radius.

height : real

width : real

Definisce la larghezza e l'altezza del rettangolo.

Vedi anche x e y.

radius : real

Questa proprietà definisce il raggio degli angoli utilizzato per definire un rettangolo arrotondato.

Se il raggio è un valore positivo, il tracciato del rettangolo verrà definito come rettangolo arrotondato, altrimenti verrà definito come rettangolo normale.

Questa proprietà può essere sovrascritta dalle singole proprietà relative al raggio degli angoli.

Il valore predefinito è 0.

Vedi anche topLeftRadius, topRightRadius, bottomLeftRadius e bottomRightRadius.

relativeX : real

relativeY : real

Definisce l'angolo superiore sinistro del rettangolo rispetto al punto iniziale del percorso.

Se per un singolo asse vengono specificate sia una posizione finale relativa che una assoluta, verrà utilizzata la posizione relativa.

È possibile combinare posizioni relative e assolute; ad esempio, è valido impostare una x relativa e una y assoluta.

Vedi anche x e y.

strokeAdjustment : real

Questa proprietà definisce la regolazione della larghezza del tratto in base alle coordinate del rettangolo.

Se utilizzata in un elemento " ShapePath " con la funzione di contorno abilitata, il rettangolo effettivamente contornato si estenderà, per impostazione predefinita, oltre il rettangolo definito di metà della larghezza del tratto su tutti i lati. Questo è il comportamento previsto, poiché il percorso definisce la linea mediana del contorno e corrisponde al rendering di QPainter e SVG.

Se invece si desidera che il rettangolo definito costituisca il bordo esterno del rettangolo tracciato, come un elemento " Rectangle " con un bordo, è possibile impostare `strokeAdjustment` sul valore della larghezza del tratto. Ciò sposterà effettivamente tutti i bordi verso l’interno di metà della larghezza del tratto. Come nell’esempio seguente:

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

Definisce l'angolo superiore sinistro del rettangolo.

A meno che quell'angolo non sia arrotondato, questo sarà anche il punto iniziale e finale del percorso.

Vedi anche relativeX e 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.