qml item Rectangle
时间: 2023-05-26 21:02:13 浏览: 118
The Rectangle element is used to define a rectangular shape within a QML item. It is the simplest shape element available in QML and can be used to fill a region with color or image.
Example:
```
Rectangle {
width: 200
height: 100
color: "blue"
}
```
This code will create a blue rectangle that is 200 units wide and 100 units high. The `color` property sets the fill color of the rectangle.
Additional properties of the Rectangle element include:
- `border`: Defines the border of the rectangle
- `border.width`: Sets the width of the border
- `border.color`: Sets the color of the border
- `radius`: Sets the corner radius of the rectangle
- `gradient`: Defines a gradient fill for the rectangle
- `image`: Sets an image as the fill of the rectangle
The Rectangle element can also be used as a container for other QML items by using the `contentItem` property. This property defines the area within the rectangle where the content of the container should be placed.
阅读全文