equal
deleted
inserted
replaced
112 colors are specified at their position in the range 0.0 - 1.0 via |
112 colors are specified at their position in the range 0.0 - 1.0 via |
113 the GradientStop item. For example, the following code paints a |
113 the GradientStop item. For example, the following code paints a |
114 rectangle with a gradient starting with red, blending to yellow at 1/3 of the |
114 rectangle with a gradient starting with red, blending to yellow at 1/3 of the |
115 size of the rectangle, and ending with Green: |
115 size of the rectangle, and ending with Green: |
116 |
116 |
117 \table |
117 \snippet doc/src/snippets/declarative/gradient.qml code |
118 \row |
118 |
119 \o \image gradient.png |
119 Note that this item is not a visual representation of a gradient. To display a |
120 \o \quotefile doc/src/snippets/declarative/gradient.qml |
120 gradient use a visual item (like rectangle) which supports having a gradient set |
121 \endtable |
121 on it for display. |
122 |
122 |
123 \sa GradientStop |
123 \sa GradientStop |
124 */ |
124 */ |
125 |
125 |
126 /*! |
126 /*! |
158 |
158 |
159 A Rectangle is painted using a solid fill (color) and an optional border. |
159 A Rectangle is painted using a solid fill (color) and an optional border. |
160 You can also create rounded rectangles using the \l radius property. |
160 You can also create rounded rectangles using the \l radius property. |
161 |
161 |
162 \qml |
162 \qml |
|
163 import Qt 4.7 |
|
164 |
163 Rectangle { |
165 Rectangle { |
164 width: 100 |
166 width: 100 |
165 height: 100 |
167 height: 100 |
166 color: "red" |
168 color: "red" |
167 border.color: "black" |
169 border.color: "black" |
200 |
202 |
201 The width and color used to draw the border of the rectangle. |
203 The width and color used to draw the border of the rectangle. |
202 |
204 |
203 A width of 1 creates a thin line. For no line, use a width of 0 or a transparent color. |
205 A width of 1 creates a thin line. For no line, use a width of 0 or a transparent color. |
204 |
206 |
205 To keep the border smooth (rather than blurry), odd widths cause the rectangle to be painted at |
207 If \c border.width is an odd number, the rectangle is painted at a half-pixel offset to retain |
206 a half-pixel offset; |
208 border smoothness. Also, the border is rendered evenly on either side of the |
|
209 rectangle's boundaries, and the spare pixel is rendered to the right and below the |
|
210 rectangle (as documented for QRect rendering). This can cause unintended effects if |
|
211 \c border.width is 1 and the rectangle is \l{Item::clip}{clipped} by a parent item: |
|
212 |
|
213 \table |
|
214 \row |
|
215 \o \snippet doc/src/snippets/declarative/rect-border-width.qml 0 |
|
216 \o \image rect-border-width.png |
|
217 \endtable |
|
218 |
|
219 Here, the innermost rectangle's border is clipped on the bottom and right edges by its |
|
220 parent. To avoid this, the border width can be set to two instead of one. |
207 */ |
221 */ |
208 QDeclarativePen *QDeclarativeRectangle::border() |
222 QDeclarativePen *QDeclarativeRectangle::border() |
209 { |
223 { |
210 Q_D(QDeclarativeRectangle); |
224 Q_D(QDeclarativeRectangle); |
211 return d->getPen(); |
225 return d->getPen(); |
430 bool oldAA = p.testRenderHint(QPainter::Antialiasing); |
444 bool oldAA = p.testRenderHint(QPainter::Antialiasing); |
431 if (d->smooth) |
445 if (d->smooth) |
432 p.setRenderHint(QPainter::Antialiasing); |
446 p.setRenderHint(QPainter::Antialiasing); |
433 if (d->pen && d->pen->isValid()) { |
447 if (d->pen && d->pen->isValid()) { |
434 QPen pn(QColor(d->pen->color()), d->pen->width()); |
448 QPen pn(QColor(d->pen->color()), d->pen->width()); |
|
449 pn.setJoinStyle(Qt::MiterJoin); |
435 p.setPen(pn); |
450 p.setPen(pn); |
436 } else { |
451 } else { |
437 p.setPen(Qt::NoPen); |
452 p.setPen(Qt::NoPen); |
438 } |
453 } |
439 if (d->gradient && d->gradient->gradient()) |
454 if (d->gradient && d->gradient->gradient()) |