![]() |
Home · All Classes · All Functions · Overviews |
[Inherits Item]
The Rectangle item allows you to add rectangles to a scene. More...
|
A Rectangle is painted having a solid fill (color) and an optional border. You can also create rounded rectangles using the radius property.
Rectangle { width: 100 height: 100 color: "red" border.color: "black" border.width: 5 radius: 10 }
The width and color used to draw the border of the rectangle.
A width of 1 creates a thin line. For no line, use a width of 0 or a transparent color.
To keep the border smooth (rather than blurry), odd widths cause the rectangle to be painted at a half-pixel offset;
color : color |
This property holds the color used to fill the rectangle.
// green rectangle using hexidecimal notation
Rectangle { color: "#00FF00" }
// steelblue rectangle using SVG color name
Rectangle { color: "steelblue" }
The default color is white.
If both a gradient and a color are specified, the gradient will be used.
gradient : Gradient |
The gradient to use to fill the rectangle.
This property allows for the construction of simple vertical gradients. Other gradients may by formed by adding rotation to the rectangle.
Rectangle { y: 0; width: 80; height: 80; color: "lightsteelblue" }
Rectangle { y: 100; width: 80; height: 80
gradient: Gradient {
GradientStop { position: 0.0; color: "lightsteelblue" }
GradientStop { position: 1.0; color: "blue" }
}
}
Rectangle { rotation: 90; x: 80; y: 200; width: 80; height: 80
gradient: Gradient {
GradientStop { position: 0.0; color: "lightsteelblue" }
GradientStop { position: 1.0; color: "blue" }
}
}
// The x offset is needed because the rotation is from the top left corner
|
If both a gradient and a color are specified, the gradient will be used.
radius : real |
This property holds the corner radius used to draw a rounded rectangle.
If radius is non-zero, the rectangle will be painted as a rounded rectangle, otherwise it will be painted as a normal rectangle. The same radius is used by all 4 corners; there is currently no way to specify different radii for different corners.
smooth : bool |
Set this property if you want the item to be smoothly scaled or transformed. Smooth filtering gives better visual quality, but is slower. If the item is displayed at its natural size, this property has no visual or performance effect.
Note: Generally scaling artifacts are only visible if the item is stationary on the screen. A common pattern when animating an item is to disable smooth filtering at the beginning of the animation and reenable it at the conclusion.
Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies) | Trademarks | Qt 4.7.0 |