En esta página

PathRectangle QML Type

Define un rectángulo con esquinas redondeadas (opcionalmente). Más...

Import Statement: import QtQuick
Since: QtQuick 6.8

Propiedades

Descripción detallada

PathRectangle ofrece una forma sencilla de especificar un rectángulo, opcionalmente con esquinas redondeadas o biseladas. La API se corresponde con la del elemento Rectangle.

Rectángulo con esquinas biseladas

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

Véase también Path, PathLine, PathQuad, PathCubic, PathArc, PathAngleArc, PathCurve y PathSvg.

Documentación de la propiedad

bevel : bool [since 6.10]

Esta propiedad define si las esquinas del rectángulo están biseladas.

Si se establece en « false », se obtienen esquinas afiladas o redondeadas, dependiendo de los valores de las propiedades individuales « radius ».

Esta propiedad puede ser anulada por las propiedades de bisel individuales.

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

Rectángulo con las esquinas superior izquierda e inferior derecha biseladas

Esta propiedad se introdujo en Qt 6.10.

Véase también « topLeftBevel », « topRightBevel », « bottomLeftBevel » y « bottomRightBevel ».

bottomLeftBevel : bool

bottomRightBevel : bool

topLeftBevel : bool

topRightBevel : bool

Si se configuran, estas propiedades definen los biseles de cada esquina. Al establecerlas en « false », se obtienen esquinas afiladas o redondeadas, dependiendo de los valores de las propiedades individuales « radius ». Al establecerlas en « true », se obtienen esquinas biseladas. Cuando no se configuran, se utiliza en su lugar el valor de « bevel ».

Estas propiedades están desactivadas por defecto. Asigna undefined a estas propiedades para volver a desactivarlas.

En el siguiente ejemplo, bottomRightBevel se establece en «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 rectangular con tres esquinas redondeadas y una esquina biselada

Véase también bevel.

bottomLeftRadius : real

bottomRightRadius : real

topLeftRadius : real

topRightRadius : real

Si se establecen, estas propiedades definen los radios de las esquinas individuales. Un valor cero indica que la esquina es afilada, mientras que un valor positivo indica que es redondeada. Cuando no se establecen, se utiliza en su lugar el valor de ` radius `.

Estas propiedades están desactivadas por defecto. Asigna « undefined » a ellas para volver a desactivarlas.

En el siguiente ejemplo, radius se establece en 10 y topLeftRadius en 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 rectangular con tres esquinas redondeadas y una esquina biselada

Véase también « radius ».

height : real

width : real

Define la anchura y la altura del rectángulo.

Véase también x y y.

radius : real

Esta propiedad define el radio de las esquinas que se utiliza para definir un rectángulo redondeado.

Si el radio es un valor positivo, la ruta del rectángulo se definirá como un rectángulo redondeado; en caso contrario, se definirá como un rectángulo normal.

Esta propiedad puede ser anulada por las propiedades individuales de radio de las esquinas.

El valor por defecto es 0.

Véase también « topLeftRadius », « topRightRadius », « bottomLeftRadius » y « bottomRightRadius ».

relativeX : real

relativeY : real

Define la esquina superior izquierda del rectángulo con respecto al punto inicial de la ruta.

Si se especifican tanto una posición final relativa como una absoluta para un mismo eje, se utilizará la posición relativa.

Se pueden combinar posiciones relativas y absolutas; por ejemplo, es válido establecer una x relativa y una y absoluta.

Véase también x y y.

strokeAdjustment : real

Esta propiedad define el ajuste del ancho del trazo a las coordenadas del rectángulo.

Cuando se utiliza en un elemento « ShapePath » con el trazo activado, el rectángulo trazado real se extenderá, por defecto, más allá del rectángulo definido en la mitad del ancho del trazo por todos los lados. Este es el comportamiento esperado, ya que la ruta define la línea del punto medio del trazo y se corresponde con la representación de « QPainter » y SVG.

Si, por el contrario, se desea que el rectángulo definido sea el borde exterior del rectángulo trazado, como un elemento « Rectangle » con borde, se puede establecer «strokeAdjustment» en el ancho del trazo. Esto desplazará efectivamente todos los bordes hacia dentro en la mitad del ancho del trazo. Como en el siguiente ejemplo:

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

Define la esquina superior izquierda del rectángulo.

A menos que esa esquina esté redondeada, este será también el punto inicial y final del trazado.

Véase también relativeX y 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.