Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qdrawutil.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#include "qdrawutil.h"
6#include "qbitmap.h"
7#include "qpixmapcache.h"
8#include "qpainter.h"
10#include "qpalette.h"
11#include "qstylehelper_p.h"
12#include <private/qpaintengineex_p.h>
13#include <qvarlengtharray.h>
14#include <qmath.h>
15#include <private/qhexstring_p.h>
16
18
19/*!
20 \headerfile <qdrawutil.h>
21 \inmodule QtWidgets
22 \title Drawing Utility Functions
23
24 \sa QPainter
25*/
26
27/*!
28 \fn void qDrawShadeLine(QPainter *painter, int x1, int y1, int x2, int y2,
29 const QPalette &palette, bool sunken,
30 int lineWidth, int midLineWidth)
31 \relates <qdrawutil.h>
32
33 Draws a horizontal (\a y1 == \a y2) or vertical (\a x1 == \a x2)
34 shaded line using the given \a painter. Note that nothing is
35 drawn if \a y1 != \a y2 and \a x1 != \a x2 (i.e. the line is
36 neither horizontal nor vertical).
37
38 The provided \a palette specifies the shading colors (\l
39 {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
40 {QPalette::mid()}{middle} colors). The given \a lineWidth
41 specifies the line width for each of the lines; it is not the
42 total line width. The given \a midLineWidth specifies the width of
43 a middle line drawn in the QPalette::mid() color.
44
45 The line appears sunken if \a sunken is true, otherwise raised.
46
47 \warning This function does not look at QWidget::style() or
48 QApplication::style(). Use the drawing functions in QStyle to
49 make widgets that follow the current GUI style.
50
51
52 Alternatively you can use a QFrame widget and apply the
53 QFrame::setFrameStyle() function to display a shaded line:
54
55 \snippet code/src_gui_painting_qdrawutil.cpp 0
56
57 \sa qDrawShadeRect(), qDrawShadePanel(), QStyle
58*/
59
60void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2,
61 const QPalette &pal, bool sunken,
62 int lineWidth, int midLineWidth)
63{
64 if (Q_UNLIKELY(!p || lineWidth < 0 || midLineWidth < 0)) {
65 qWarning("qDrawShadeLine: Invalid parameters");
66 return;
67 }
68 QPainterStateGuard painterGuard(p);
69 const qreal devicePixelRatio = QStyleHelper::getDpr(p);
70 if (!qFuzzyCompare(devicePixelRatio, qreal(1))) {
71 const qreal inverseScale = qreal(1) / devicePixelRatio;
72 p->scale(inverseScale, inverseScale);
73 x1 = qRound(devicePixelRatio * x1);
74 y1 = qRound(devicePixelRatio * y1);
75 x2 = qRound(devicePixelRatio * x2);
76 y2 = qRound(devicePixelRatio * y2);
77 lineWidth = qRound(devicePixelRatio * lineWidth);
78 midLineWidth = qRound(devicePixelRatio * midLineWidth);
79 p->translate(0.5, 0.5);
80 }
81 int tlw = lineWidth*2 + midLineWidth; // total line width
82 if (sunken)
83 p->setPen(pal.color(QPalette::Dark));
84 else
85 p->setPen(pal.light().color());
86 QPolygon a;
87 int i;
88 if (y1 == y2) { // horizontal line
89 int y = y1 - tlw/2;
90 if (x1 > x2) { // swap x1 and x2
91 int t = x1;
92 x1 = x2;
93 x2 = t;
94 }
95 x2--;
96 for (i=0; i<lineWidth; i++) { // draw top shadow
97 a.setPoints(3, x1+i, y+tlw-1-i,
98 x1+i, y+i,
99 x2-i, y+i);
100 p->drawPolyline(a);
101 }
102 if (midLineWidth > 0) {
103 p->setPen(pal.mid().color());
104 for (i=0; i<midLineWidth; i++) // draw lines in the middle
105 p->drawLine(x1+lineWidth, y+lineWidth+i,
106 x2-lineWidth, y+lineWidth+i);
107 }
108 if (sunken)
109 p->setPen(pal.light().color());
110 else
111 p->setPen(pal.dark().color());
112 for (i=0; i<lineWidth; i++) { // draw bottom shadow
113 a.setPoints(3, x1+i, y+tlw-i-1,
114 x2-i, y+tlw-i-1,
115 x2-i, y+i+1);
116 p->drawPolyline(a);
117 }
118 }
119 else if (x1 == x2) { // vertical line
120 int x = x1 - tlw/2;
121 if (y1 > y2) { // swap y1 and y2
122 int t = y1;
123 y1 = y2;
124 y2 = t;
125 }
126 y2--;
127 for (i=0; i<lineWidth; i++) { // draw left shadow
128 a.setPoints(3, x+i, y2,
129 x+i, y1+i,
130 x+tlw-1, y1+i);
131 p->drawPolyline(a);
132 }
133 if (midLineWidth > 0) {
134 p->setPen(pal.mid().color());
135 for (i=0; i<midLineWidth; i++) // draw lines in the middle
136 p->drawLine(x+lineWidth+i, y1+lineWidth, x+lineWidth+i, y2);
137 }
138 if (sunken)
139 p->setPen(pal.light().color());
140 else
141 p->setPen(pal.dark().color());
142 for (i=0; i<lineWidth; i++) { // draw right shadow
143 a.setPoints(3, x+lineWidth, y2-i,
144 x+tlw-i-1, y2-i,
145 x+tlw-i-1, y1+lineWidth);
146 p->drawPolyline(a);
147 }
148 }
149}
150
151/*!
152 \fn void qDrawShadeRect(QPainter *painter, int x, int y, int width, int height,
153 const QPalette &palette, bool sunken,
154 int lineWidth, int midLineWidth,
155 const QBrush *fill)
156 \relates <qdrawutil.h>
157
158 Draws the shaded rectangle beginning at (\a x, \a y) with the
159 given \a width and \a height using the provided \a painter.
160
161 The provide \a palette specifies the shading colors (\l
162 {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
163 {QPalette::mid()}{middle} colors. The given \a lineWidth
164 specifies the line width for each of the lines; it is not the
165 total line width. The \a midLineWidth specifies the width of a
166 middle line drawn in the QPalette::mid() color. The rectangle's
167 interior is filled with the \a fill brush unless \a fill is \nullptr.
168
169 The rectangle appears sunken if \a sunken is true, otherwise
170 raised.
171
172 \warning This function does not look at QWidget::style() or
173 QApplication::style(). Use the drawing functions in QStyle to make
174 widgets that follow the current GUI style.
175
176 Alternatively you can use a QFrame widget and apply the
177 QFrame::setFrameStyle() function to display a shaded rectangle:
178
179 \snippet code/src_gui_painting_qdrawutil.cpp 1
180
181 \sa qDrawShadeLine(), qDrawShadePanel(), qDrawPlainRect(), QStyle
182*/
183
184void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
185 const QPalette &pal, bool sunken,
186 int lineWidth, int midLineWidth,
187 const QBrush *fill)
188{
189 if (w == 0 || h == 0)
190 return;
191 if (Q_UNLIKELY(w < 0 || h < 0 || lineWidth < 0 || midLineWidth < 0)) {
192 qWarning("qDrawShadeRect: Invalid parameters");
193 return;
194 }
195
196 QPainterStateGuard painterGuard(p);
197 const qreal devicePixelRatio = QStyleHelper::getDpr(p);
198 if (!qFuzzyCompare(devicePixelRatio, qreal(1))) {
199 const qreal inverseScale = qreal(1) / devicePixelRatio;
200 p->scale(inverseScale, inverseScale);
201 x = qRound(devicePixelRatio * x);
202 y = qRound(devicePixelRatio * y);
203 w = devicePixelRatio * w;
204 h = devicePixelRatio * h;
205 lineWidth = qRound(devicePixelRatio * lineWidth);
206 midLineWidth = qRound(devicePixelRatio * midLineWidth);
207 p->translate(0.5, 0.5);
208 }
209 if (sunken)
210 p->setPen(pal.dark().color());
211 else
212 p->setPen(pal.light().color());
213 int x1=x, y1=y, x2=x+w-1, y2=y+h-1;
214
215 if (lineWidth == 1 && midLineWidth == 0) {// standard shade rectangle
216 p->drawRect(x1, y1, w-2, h-2);
217 if (sunken)
218 p->setPen(pal.light().color());
219 else
220 p->setPen(pal.dark().color());
221 QLineF lines[4] = { QLineF(x1+1, y1+1, x2-2, y1+1),
222 QLineF(x1+1, y1+2, x1+1, y2-2),
223 QLineF(x1, y2, x2, y2),
224 QLineF(x2,y1, x2,y2-1) };
225 p->drawLines(lines, 4); // draw bottom/right lines
226 } else { // more complicated
227 int m = lineWidth+midLineWidth;
228 int i, j=0, k=m;
229 for (i=0; i<lineWidth; i++) { // draw top shadow
230 QLineF lines[4] = { QLineF(x1+i, y2-i, x1+i, y1+i),
231 QLineF(x1+i, y1+i, x2-i, y1+i),
232 QLineF(x1+k, y2-k, x2-k, y2-k),
233 QLineF(x2-k, y2-k, x2-k, y1+k) };
234 p->drawLines(lines, 4);
235 k++;
236 }
237 p->setPen(pal.mid().color());
238 j = lineWidth*2;
239 for (i=0; i<midLineWidth; i++) { // draw lines in the middle
240 p->drawRect(x1+lineWidth+i, y1+lineWidth+i, w-j-1, h-j-1);
241 j += 2;
242 }
243 if (sunken)
244 p->setPen(pal.light().color());
245 else
246 p->setPen(pal.dark().color());
247 k = m;
248 for (i=0; i<lineWidth; i++) { // draw bottom shadow
249 QLineF lines[4] = { QLineF(x1+1+i, y2-i, x2-i, y2-i),
250 QLineF(x2-i, y2-i, x2-i, y1+i+1),
251 QLineF(x1+k, y2-k, x1+k, y1+k),
252 QLineF(x1+k, y1+k, x2-k, y1+k) };
253 p->drawLines(lines, 4);
254 k++;
255 }
256 }
257 if (fill) {
258 int tlw = lineWidth + midLineWidth;
259 p->setPen(Qt::NoPen);
260 p->setBrush(*fill);
261 p->drawRect(x+tlw, y+tlw, w-2*tlw, h-2*tlw);
262 }
263}
264
265/*!
266 \fn void qDrawShadePanel(QPainter *painter, int x, int y, int width, int height,
267 const QPalette &palette, bool sunken,
268 int lineWidth, const QBrush *fill)
269 \relates <qdrawutil.h>
270
271 Draws the shaded panel beginning at (\a x, \a y) with the given \a
272 width and \a height using the provided \a painter and the given \a
273 lineWidth.
274
275 The given \a palette specifies the shading colors (\l
276 {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
277 {QPalette::mid()}{middle} colors). The panel's interior is filled
278 with the \a fill brush unless \a fill is \nullptr.
279
280 The panel appears sunken if \a sunken is true, otherwise raised.
281
282 \warning This function does not look at QWidget::style() or
283 QApplication::style(). Use the drawing functions in QStyle to make
284 widgets that follow the current GUI style.
285
286 Alternatively you can use a QFrame widget and apply the
287 QFrame::setFrameStyle() function to display a shaded panel:
288
289 \snippet code/src_gui_painting_qdrawutil.cpp 2
290
291 \sa qDrawWinPanel(), qDrawShadeLine(), qDrawShadeRect(), QStyle
292*/
293
294void qDrawShadePanel(QPainter *p, int x, int y, int w, int h,
295 const QPalette &pal, bool sunken,
296 int lineWidth, const QBrush *fill)
297{
298 if (w == 0 || h == 0)
299 return;
300 if (Q_UNLIKELY(w < 0 || h < 0 || lineWidth < 0)) {
301 qWarning("qDrawShadePanel: Invalid parameters");
302 }
303
304 QPainterStateGuard painterGuard(p);
305 const qreal devicePixelRatio = QStyleHelper::getDpr(p);
306 bool isTranslated = false;
307 if (!qFuzzyCompare(devicePixelRatio, qreal(1))) {
308 const qreal inverseScale = qreal(1) / devicePixelRatio;
309 p->scale(inverseScale, inverseScale);
310 x = qRound(devicePixelRatio * x);
311 y = qRound(devicePixelRatio * y);
312 w = devicePixelRatio * w;
313 h = devicePixelRatio * h;
314 lineWidth = qRound(devicePixelRatio * lineWidth);
315 p->translate(0.5, 0.5);
316 isTranslated = true;
317 }
318
319 QColor shade = pal.dark().color();
320 QColor light = pal.light().color();
321 if (fill) {
322 if (fill->color() == shade)
323 shade = pal.shadow().color();
324 if (fill->color() == light)
325 light = pal.midlight().color();
326 }
327 QList<QLineF> lines;
328 lines.reserve(2*lineWidth);
329
330 if (sunken)
331 p->setPen(shade);
332 else
333 p->setPen(light);
334 int x1, y1, x2, y2;
335 int i;
336 x1 = x;
337 y1 = y2 = y;
338 x2 = x+w-2;
339 for (i=0; i<lineWidth; i++) { // top shadow
340 lines << QLineF(x1, y1++, x2--, y2++);
341 }
342 x2 = x1;
343 y1 = y+h-2;
344 for (i=0; i<lineWidth; i++) { // left shado
345 lines << QLineF(x1++, y1, x2++, y2--);
346 }
347 p->drawLines(lines);
348 lines.clear();
349 if (sunken)
350 p->setPen(light);
351 else
352 p->setPen(shade);
353 x1 = x;
354 y1 = y2 = y+h-1;
355 x2 = x+w-1;
356 for (i=0; i<lineWidth; i++) { // bottom shadow
357 lines << QLineF(x1++, y1--, x2, y2--);
358 }
359 x1 = x2;
360 y1 = y;
361 y2 = y+h-lineWidth-1;
362 for (i=0; i<lineWidth; i++) { // right shadow
363 lines << QLineF(x1--, y1++, x2--, y2);
364 }
365 p->drawLines(lines);
366 if (fill) { // fill with fill color
367 if (isTranslated)
368 p->translate(-0.5, -0.5);
369 p->fillRect(x+lineWidth, y+lineWidth, w-lineWidth*2, h-lineWidth*2, *fill);
370 }
371}
372
373/*!
374 \internal
375 This function draws a rectangle with two pixel line width.
376 It is called from qDrawWinButton() and qDrawWinPanel().
377
378 c1..c4 and fill are used:
379
380 1 1 1 1 1 2
381 1 3 3 3 4 2
382 1 3 F F 4 2
383 1 3 F F 4 2
384 1 4 4 4 4 2
385 2 2 2 2 2 2
386*/
387
389 int x, int y, int w, int h,
390 const QColor &c1, const QColor &c2,
391 const QColor &c3, const QColor &c4,
392 const QBrush *fill)
393{
394 if (w < 2 || h < 2) // can't do anything with that
395 return;
396
397 QPainterStateGuard painterGuard(p);
398 const qreal devicePixelRatio = QStyleHelper::getDpr(p);
399 bool isTranslated = false;
400 if (!qFuzzyCompare(devicePixelRatio, qreal(1))) {
401 const qreal inverseScale = qreal(1) / devicePixelRatio;
402 p->scale(inverseScale, inverseScale);
403 x = qRound(devicePixelRatio * x);
404 y = qRound(devicePixelRatio * y);
405 w = devicePixelRatio * w;
406 h = devicePixelRatio * h;
407 p->translate(0.5, 0.5);
408 isTranslated = true;
409 }
410
411 QPoint a[3] = { QPoint(x, y+h-2), QPoint(x, y), QPoint(x+w-2, y) };
412 p->setPen(c1);
413 p->drawPolyline(a, 3);
414 QPoint b[3] = { QPoint(x, y+h-1), QPoint(x+w-1, y+h-1), QPoint(x+w-1, y) };
415 p->setPen(c2);
416 p->drawPolyline(b, 3);
417 if (w > 4 && h > 4) {
418 QPoint c[3] = { QPoint(x+1, y+h-3), QPoint(x+1, y+1), QPoint(x+w-3, y+1) };
419 p->setPen(c3);
420 p->drawPolyline(c, 3);
421 QPoint d[3] = { QPoint(x+1, y+h-2), QPoint(x+w-2, y+h-2), QPoint(x+w-2, y+1) };
422 p->setPen(c4);
423 p->drawPolyline(d, 3);
424 if (fill) {
425 if (isTranslated)
426 p->translate(-0.5, -0.5);
427 p->fillRect(QRect(x+2, y+2, w-4, h-4), *fill);
428 }
429 }
430}
431
432
433/*!
434 \fn void qDrawWinButton(QPainter *painter, int x, int y, int width, int height,
435 const QPalette &palette, bool sunken,
436 const QBrush *fill)
437 \relates <qdrawutil.h>
438
439 Draws the Windows-style button specified by the given point (\a x,
440 \a y}, \a width and \a height using the provided \a painter with a
441 line width of 2 pixels. The button's interior is filled with the
442 \a{fill} brush unless \a fill is \nullptr.
443
444 The given \a palette specifies the shading colors (\l
445 {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
446 {QPalette::mid()}{middle} colors).
447
448 The button appears sunken if \a sunken is true, otherwise raised.
449
450 \warning This function does not look at QWidget::style() or
451 QApplication::style()-> Use the drawing functions in QStyle to make
452 widgets that follow the current GUI style.
453
454 \sa qDrawWinPanel(), QStyle
455*/
456
457void qDrawWinButton(QPainter *p, int x, int y, int w, int h,
458 const QPalette &pal, bool sunken,
459 const QBrush *fill)
460{
461 if (sunken)
462 qDrawWinShades(p, x, y, w, h,
463 pal.shadow().color(), pal.light().color(), pal.dark().color(),
464 pal.button().color(), fill);
465 else
466 qDrawWinShades(p, x, y, w, h,
467 pal.light().color(), pal.shadow().color(), pal.button().color(),
468 pal.dark().color(), fill);
469}
470
471/*!
472 \fn void qDrawWinPanel(QPainter *painter, int x, int y, int width, int height,
473 const QPalette &palette, bool sunken,
474 const QBrush *fill)
475 \relates <qdrawutil.h>
476
477 Draws the Windows-style panel specified by the given point(\a x,
478 \a y), \a width and \a height using the provided \a painter with a
479 line width of 2 pixels. The button's interior is filled with the
480 \a fill brush unless \a fill is \nullptr.
481
482 The given \a palette specifies the shading colors. The panel
483 appears sunken if \a sunken is true, otherwise raised.
484
485 \warning This function does not look at QWidget::style() or
486 QApplication::style(). Use the drawing functions in QStyle to make
487 widgets that follow the current GUI style.
488
489 Alternatively you can use a QFrame widget and apply the
490 QFrame::setFrameStyle() function to display a shaded panel:
491
492 \snippet code/src_gui_painting_qdrawutil.cpp 3
493
494 \sa qDrawShadePanel(), qDrawWinButton(), QStyle
495*/
496
497void qDrawWinPanel(QPainter *p, int x, int y, int w, int h,
498 const QPalette &pal, bool sunken,
499 const QBrush *fill)
500{
501 if (sunken)
502 qDrawWinShades(p, x, y, w, h,
503 pal.dark().color(), pal.light().color(), pal.shadow().color(),
504 pal.midlight().color(), fill);
505 else
506 qDrawWinShades(p, x, y, w, h,
507 pal.light().color(), pal.shadow().color(), pal.midlight().color(),
508 pal.dark().color(), fill);
509}
510
511/*!
512 \fn void qDrawPlainRect(QPainter *painter, int x, int y, int width, int height, const QColor &lineColor,
513 int lineWidth, const QBrush *fill)
514 \relates <qdrawutil.h>
515
516 Draws the plain rectangle beginning at (\a x, \a y) with the given
517 \a width and \a height, using the specified \a painter, \a lineColor
518 and \a lineWidth. The rectangle's interior is filled with the \a
519 fill brush unless \a fill is \nullptr.
520
521 \warning This function does not look at QWidget::style() or
522 QApplication::style(). Use the drawing functions in QStyle to make
523 widgets that follow the current GUI style.
524
525 Alternatively you can use a QFrame widget and apply the
526 QFrame::setFrameStyle() function to display a plain rectangle:
527
528 \snippet code/src_gui_painting_qdrawutil.cpp 4
529
530 \sa qDrawShadeRect(), QStyle
531*/
532
533void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &c,
534 int lineWidth, const QBrush *fill)
535{
536 if (w == 0 || h == 0)
537 return;
538 if (Q_UNLIKELY(w < 0 || h < 0 || lineWidth < 0)) {
539 qWarning("qDrawPlainRect: Invalid parameters");
540 return;
541 }
542
543 QPainterStateGuard painterGuard(p);
544 if (lineWidth == 0 && !fill)
545 return;
546 if (lineWidth > 0)
547 p->setPen(QPen(c, lineWidth, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin));
548 p->setBrush(fill ? *fill : Qt::NoBrush);
549 const QRectF r(x, y, w, h);
550 const auto lw2 = lineWidth / 2.;
551 const QRectF rect = r.marginsRemoved(QMarginsF(lw2, lw2, lw2, lw2));
552 p->drawRect(rect);
553}
554
555/*!
556 \fn void qDrawPlainRoundedRect(QPainter *painter, int x, int y,
557 int width, int height, qreal rx, qreal ry,
558 const QColor &lineColor, int lineWidth,
559 const QBrush *fill)
560 \since 6.7
561 \relates <qdrawutil.h>
562
563 Draws the plain rounded rectangle beginning at (\a x, \a y)
564 with the given \a width and \a height,
565 using the horizontal \a rx and vertical radius \a ry,
566 specified \a painter, \a lineColor and \a lineWidth.
567 The rectangle's interior is filled with the \a
568 fill brush unless \a fill is \nullptr.
569
570 \warning This function does not look at QWidget::style() or
571 QApplication::style(). Use the drawing functions in QStyle to make
572 widgets that follow the current GUI style.
573
574 Alternatively you can use a QFrame widget and apply the
575 QFrame::setFrameStyle() function to display a plain rectangle:
576
577 \snippet code/src_gui_painting_qdrawutil.cpp 4
578
579 \sa qDrawShadeRect(), QStyle
580*/
581
582// ### Qt7: Pass QPen instead of QColor for frame drawing
583void qDrawPlainRoundedRect(QPainter *p, int x, int y, int w, int h,
584 qreal rx, qreal ry, const QColor &c,
585 int lineWidth, const QBrush *fill)
586{
587 if (w == 0 || h == 0)
588 return;
589 if (Q_UNLIKELY(w < 0 || h < 0 || lineWidth < 0)) {
590 qWarning("qDrawPlainRect: Invalid parameters");
591 return;
592 }
593
594 QPainterStateGuard painterGuard(p);
595 if (lineWidth == 0 && !fill)
596 return;
597 if (lineWidth > 0)
598 p->setPen(QPen(c, lineWidth));
599 p->setBrush(fill ? *fill : Qt::NoBrush);
600 const QRectF r(x, y, w, h);
601 const auto lw2 = lineWidth / 2.;
602 const QRectF rect = r.marginsRemoved(QMarginsF(lw2, lw2, lw2, lw2));
603 p->drawRoundedRect(rect, rx, ry);
604}
605
606/*****************************************************************************
607 Overloaded functions.
608 *****************************************************************************/
609
610/*!
611 \fn void qDrawShadeLine(QPainter *painter, const QPoint &p1, const QPoint &p2,
612 const QPalette &palette, bool sunken, int lineWidth, int midLineWidth)
613 \relates <qdrawutil.h>
614 \overload
615
616 Draws a horizontal or vertical shaded line between \a p1 and \a p2
617 using the given \a painter. Note that nothing is drawn if the line
618 between the points would be neither horizontal nor vertical.
619
620 The provided \a palette specifies the shading colors (\l
621 {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
622 {QPalette::mid()}{middle} colors). The given \a lineWidth
623 specifies the line width for each of the lines; it is not the
624 total line width. The given \a midLineWidth specifies the width of
625 a middle line drawn in the QPalette::mid() color.
626
627 The line appears sunken if \a sunken is true, otherwise raised.
628
629 \warning This function does not look at QWidget::style() or
630 QApplication::style(). Use the drawing functions in QStyle to
631 make widgets that follow the current GUI style.
632
633
634 Alternatively you can use a QFrame widget and apply the
635 QFrame::setFrameStyle() function to display a shaded line:
636
637 \snippet code/src_gui_painting_qdrawutil.cpp 5
638
639 \sa qDrawShadeRect(), qDrawShadePanel(), QStyle
640*/
641
642void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint &p2,
643 const QPalette &pal, bool sunken,
644 int lineWidth, int midLineWidth)
645{
646 qDrawShadeLine(p, p1.x(), p1.y(), p2.x(), p2.y(), pal, sunken,
647 lineWidth, midLineWidth);
648}
649
650/*!
651 \fn void qDrawShadeRect(QPainter *painter, const QRect &rect, const QPalette &palette,
652 bool sunken, int lineWidth, int midLineWidth, const QBrush *fill)
653 \relates <qdrawutil.h>
654 \overload
655
656 Draws the shaded rectangle specified by \a rect using the given \a painter.
657
658 The provide \a palette specifies the shading colors (\l
659 {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
660 {QPalette::mid()}{middle} colors. The given \a lineWidth
661 specifies the line width for each of the lines; it is not the
662 total line width. The \a midLineWidth specifies the width of a
663 middle line drawn in the QPalette::mid() color. The rectangle's
664 interior is filled with the \a fill brush unless \a fill is \nullptr.
665
666 The rectangle appears sunken if \a sunken is true, otherwise
667 raised.
668
669 \warning This function does not look at QWidget::style() or
670 QApplication::style(). Use the drawing functions in QStyle to make
671 widgets that follow the current GUI style.
672
673 Alternatively you can use a QFrame widget and apply the
674 QFrame::setFrameStyle() function to display a shaded rectangle:
675
676 \snippet code/src_gui_painting_qdrawutil.cpp 6
677
678 \sa qDrawShadeLine(), qDrawShadePanel(), qDrawPlainRect(), QStyle
679*/
680
681void qDrawShadeRect(QPainter *p, const QRect &r,
682 const QPalette &pal, bool sunken,
683 int lineWidth, int midLineWidth,
684 const QBrush *fill)
685{
686 qDrawShadeRect(p, r.x(), r.y(), r.width(), r.height(), pal, sunken,
687 lineWidth, midLineWidth, fill);
688}
689
690/*!
691 \fn void qDrawShadePanel(QPainter *painter, const QRect &rect, const QPalette &palette,
692 bool sunken, int lineWidth, const QBrush *fill)
693 \relates <qdrawutil.h>
694 \overload
695
696 Draws the shaded panel at the rectangle specified by \a rect using the
697 given \a painter and the given \a lineWidth.
698
699 The given \a palette specifies the shading colors (\l
700 {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
701 {QPalette::mid()}{middle} colors). The panel's interior is filled
702 with the \a fill brush unless \a fill is \nullptr.
703
704 The panel appears sunken if \a sunken is true, otherwise raised.
705
706 \warning This function does not look at QWidget::style() or
707 QApplication::style(). Use the drawing functions in QStyle to make
708 widgets that follow the current GUI style.
709
710 Alternatively you can use a QFrame widget and apply the
711 QFrame::setFrameStyle() function to display a shaded panel:
712
713 \snippet code/src_gui_painting_qdrawutil.cpp 7
714
715 \sa qDrawWinPanel(), qDrawShadeLine(), qDrawShadeRect(), QStyle
716*/
717
718void qDrawShadePanel(QPainter *p, const QRect &r,
719 const QPalette &pal, bool sunken,
720 int lineWidth, const QBrush *fill)
721{
722 qDrawShadePanel(p, r.x(), r.y(), r.width(), r.height(), pal, sunken,
723 lineWidth, fill);
724}
725
726/*!
727 \fn void qDrawWinButton(QPainter *painter, const QRect &rect, const QPalette &palette,
728 bool sunken, const QBrush *fill)
729 \relates <qdrawutil.h>
730 \overload
731
732 Draws the Windows-style button at the rectangle specified by \a rect using
733 the given \a painter with a line width of 2 pixels. The button's interior
734 is filled with the \a{fill} brush unless \a fill is \nullptr.
735
736 The given \a palette specifies the shading colors (\l
737 {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
738 {QPalette::mid()}{middle} colors).
739
740 The button appears sunken if \a sunken is true, otherwise raised.
741
742 \warning This function does not look at QWidget::style() or
743 QApplication::style()-> Use the drawing functions in QStyle to make
744 widgets that follow the current GUI style.
745
746 \sa qDrawWinPanel(), QStyle
747*/
748
749void qDrawWinButton(QPainter *p, const QRect &r,
750 const QPalette &pal, bool sunken, const QBrush *fill)
751{
752 qDrawWinButton(p, r.x(), r.y(), r.width(), r.height(), pal, sunken, fill);
753}
754
755/*!
756 \fn void qDrawWinPanel(QPainter *painter, const QRect &rect, const QPalette &palette,
757 bool sunken, const QBrush *fill)
758 \relates <qdrawutil.h>
759 \overload
760
761 Draws the Windows-style panel at the rectangle specified by \a rect using
762 the given \a painter with a line width of 2 pixels. The button's interior
763 is filled with the \a fill brush unless \a fill is \nullptr.
764
765 The given \a palette specifies the shading colors. The panel
766 appears sunken if \a sunken is true, otherwise raised.
767
768 \warning This function does not look at QWidget::style() or
769 QApplication::style(). Use the drawing functions in QStyle to make
770 widgets that follow the current GUI style.
771
772 Alternatively you can use a QFrame widget and apply the
773 QFrame::setFrameStyle() function to display a shaded panel:
774
775 \snippet code/src_gui_painting_qdrawutil.cpp 8
776
777 \sa qDrawShadePanel(), qDrawWinButton(), QStyle
778*/
779
780void qDrawWinPanel(QPainter *p, const QRect &r,
781 const QPalette &pal, bool sunken, const QBrush *fill)
782{
783 qDrawWinPanel(p, r.x(), r.y(), r.width(), r.height(), pal, sunken, fill);
784}
785
786/*!
787 \fn void qDrawPlainRect(QPainter *painter, const QRect &rect, const QColor &lineColor, int lineWidth, const QBrush *fill)
788 \relates <qdrawutil.h>
789 \overload
790
791 Draws the plain rectangle specified by \a rect using the given \a painter,
792 \a lineColor and \a lineWidth. The rectangle's interior is filled with the
793 \a fill brush unless \a fill is \nullptr.
794
795 \warning This function does not look at QWidget::style() or
796 QApplication::style(). Use the drawing functions in QStyle to make
797 widgets that follow the current GUI style.
798
799 Alternatively you can use a QFrame widget and apply the
800 QFrame::setFrameStyle() function to display a plain rectangle:
801
802 \snippet code/src_gui_painting_qdrawutil.cpp 9
803
804 \sa qDrawShadeRect(), QStyle
805*/
806
807void qDrawPlainRect(QPainter *p, const QRect &r, const QColor &c,
808 int lineWidth, const QBrush *fill)
809{
810 qDrawPlainRect(p, r.x(), r.y(), r.width(), r.height(), c,
811 lineWidth, fill);
812}
813
814/*!
815 \fn void qDrawPlainRoundedRect(QPainter *painter, const QRect &rect,
816 qreal rx, qreal ry,
817 const QColor &lineColor, int lineWidth,
818 const QBrush *fill)
819 \since 6.7
820 \relates <qdrawutil.h>
821 \overload
822
823 Draws the plain rectangle specified by \a rect using
824 the horizontal \a rx and vertical radius \a ry,
825 the given \a painter, \a lineColor and \a lineWidth.
826 The rectangle's interior is filled with the
827 \a fill brush unless \a fill is \nullptr.
828
829 \warning This function does not look at QWidget::style() or
830 QApplication::style(). Use the drawing functions in QStyle to make
831 widgets that follow the current GUI style.
832
833 Alternatively you can use a QFrame widget and apply the
834 QFrame::setFrameStyle() function to display a plain rectangle:
835
836 \snippet code/src_gui_painting_qdrawutil.cpp 9
837
838 \sa qDrawShadeRect(), QStyle
839*/
840
841/*!
842 \class QTileRules
843 \since 4.6
844
845 \inmodule QtWidgets
846
847 \brief The QTileRules class provides the rules used to draw a
848 pixmap or image split into nine segments.
849
850 Spliiting is similar to \l{http://www.w3.org/TR/css3-background/}{CSS3 border-images}.
851
852 \sa Qt::TileRule, QMargins
853*/
854
855/*! \fn QTileRules::QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule)
856 Constructs a QTileRules with the given \a horizontalRule and
857 \a verticalRule.
858 */
859
860/*! \fn QTileRules::QTileRules(Qt::TileRule rule)
861 Constructs a QTileRules with the given \a rule used for both
862 the horizontal rule and the vertical rule.
863 */
864
865/*!
866 \fn void qDrawBorderPixmap(QPainter *painter, const QRect &target, const QMargins &margins, const QPixmap &pixmap)
867 \relates <qdrawutil.h>
868 \since 4.6
869
870 \brief The qDrawBorderPixmap function is for drawing a pixmap into
871 the margins of a rectangle.
872
873 Draws the given \a pixmap into the given \a target rectangle, using the
874 given \a painter. The pixmap will be split into nine segments and drawn
875 according to the \a margins structure.
876*/
877
879
880/*!
881 \relates <qdrawutil.h>
882 \since 4.6
883
884 Draws the indicated \a sourceRect rectangle from the given \a pixmap into
885 the given \a targetRect rectangle, using the given \a painter. The pixmap
886 will be split into nine segments according to the given \a targetMargins
887 and \a sourceMargins structures. Finally, the pixmap will be drawn
888 according to the given \a rules.
889
890 This function is used to draw a scaled pixmap, similar to
891 \l{http://www.w3.org/TR/css3-background/}{CSS3 border-images}
892
893 \sa Qt::TileRule, QTileRules, QMargins
894*/
895
896void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMargins,
897 const QPixmap &pixmap, const QRect &sourceRect,const QMargins &sourceMargins,
898 const QTileRules &rules
899#ifndef Q_QDOC
900 , QDrawBorderPixmap::DrawingHints hints
901#endif
902 )
903{
904 QPainter::PixmapFragment d;
905 d.opacity = 1.0;
906 d.rotation = 0.0;
907
908 QPixmapFragmentsArray opaqueData;
909 QPixmapFragmentsArray translucentData;
910
911 // source center
912 const int sourceCenterTop = sourceRect.top() + sourceMargins.top();
913 const int sourceCenterLeft = sourceRect.left() + sourceMargins.left();
914 const int sourceCenterBottom = sourceRect.bottom() - sourceMargins.bottom() + 1;
915 const int sourceCenterRight = sourceRect.right() - sourceMargins.right() + 1;
916 const int sourceCenterWidth = sourceCenterRight - sourceCenterLeft;
917 const int sourceCenterHeight = sourceCenterBottom - sourceCenterTop;
918 // target center
919 const int targetCenterTop = targetRect.top() + targetMargins.top();
920 const int targetCenterLeft = targetRect.left() + targetMargins.left();
921 const int targetCenterBottom = targetRect.bottom() - targetMargins.bottom() + 1;
922 const int targetCenterRight = targetRect.right() - targetMargins.right() + 1;
923 const int targetCenterWidth = targetCenterRight - targetCenterLeft;
924 const int targetCenterHeight = targetCenterBottom - targetCenterTop;
925
926 QVarLengthArray<qreal, 16> xTarget; // x-coordinates of target rectangles
927 QVarLengthArray<qreal, 16> yTarget; // y-coordinates of target rectangles
928
929 int columns = 3;
930 int rows = 3;
931 if (rules.horizontal != Qt::StretchTile && sourceCenterWidth != 0)
932 columns = qMax(3, 2 + qCeil(targetCenterWidth / qreal(sourceCenterWidth)));
933 if (rules.vertical != Qt::StretchTile && sourceCenterHeight != 0)
934 rows = qMax(3, 2 + qCeil(targetCenterHeight / qreal(sourceCenterHeight)));
935
936 xTarget.resize(columns + 1);
937 yTarget.resize(rows + 1);
938
939 bool oldAA = painter->testRenderHint(QPainter::Antialiasing);
940 if (painter->paintEngine()->type() != QPaintEngine::OpenGL
941 && painter->paintEngine()->type() != QPaintEngine::OpenGL2
942 && oldAA && painter->combinedTransform().type() != QTransform::TxNone) {
943 painter->setRenderHint(QPainter::Antialiasing, false);
944 }
945
946 xTarget[0] = targetRect.left();
947 xTarget[1] = targetCenterLeft;
948 xTarget[columns - 1] = targetCenterRight;
949 xTarget[columns] = targetRect.left() + targetRect.width();
950
951 yTarget[0] = targetRect.top();
952 yTarget[1] = targetCenterTop;
953 yTarget[rows - 1] = targetCenterBottom;
954 yTarget[rows] = targetRect.top() + targetRect.height();
955
956 qreal dx = targetCenterWidth;
957 qreal dy = targetCenterHeight;
958
959 switch (rules.horizontal) {
960 case Qt::StretchTile:
961 dx = targetCenterWidth;
962 break;
963 case Qt::RepeatTile:
964 dx = sourceCenterWidth;
965 break;
966 case Qt::RoundTile:
967 dx = targetCenterWidth / qreal(columns - 2);
968 break;
969 }
970
971 for (int i = 2; i < columns - 1; ++i)
972 xTarget[i] = xTarget[i - 1] + dx;
973
974 switch (rules.vertical) {
975 case Qt::StretchTile:
976 dy = targetCenterHeight;
977 break;
978 case Qt::RepeatTile:
979 dy = sourceCenterHeight;
980 break;
981 case Qt::RoundTile:
982 dy = targetCenterHeight / qreal(rows - 2);
983 break;
984 }
985
986 for (int i = 2; i < rows - 1; ++i)
987 yTarget[i] = yTarget[i - 1] + dy;
988
989 // corners
990 if (targetMargins.top() > 0 && targetMargins.left() > 0 && sourceMargins.top() > 0 && sourceMargins.left() > 0) { // top left
991 d.x = (0.5 * (xTarget[1] + xTarget[0]));
992 d.y = (0.5 * (yTarget[1] + yTarget[0]));
993 d.sourceLeft = sourceRect.left();
994 d.sourceTop = sourceRect.top();
995 d.width = sourceMargins.left();
996 d.height = sourceMargins.top();
997 d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
998 d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
999 if (hints & QDrawBorderPixmap::OpaqueTopLeft)
1000 opaqueData.append(d);
1001 else
1002 translucentData.append(d);
1003 }
1004 if (targetMargins.top() > 0 && targetMargins.right() > 0 && sourceMargins.top() > 0 && sourceMargins.right() > 0) { // top right
1005 d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
1006 d.y = (0.5 * (yTarget[1] + yTarget[0]));
1007 d.sourceLeft = sourceCenterRight;
1008 d.sourceTop = sourceRect.top();
1009 d.width = sourceMargins.right();
1010 d.height = sourceMargins.top();
1011 d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
1012 d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
1013 if (hints & QDrawBorderPixmap::OpaqueTopRight)
1014 opaqueData.append(d);
1015 else
1016 translucentData.append(d);
1017 }
1018 if (targetMargins.bottom() > 0 && targetMargins.left() > 0 && sourceMargins.bottom() > 0 && sourceMargins.left() > 0) { // bottom left
1019 d.x = (0.5 * (xTarget[1] + xTarget[0]));
1020 d.y =(0.5 * (yTarget[rows] + yTarget[rows - 1]));
1021 d.sourceLeft = sourceRect.left();
1022 d.sourceTop = sourceCenterBottom;
1023 d.width = sourceMargins.left();
1024 d.height = sourceMargins.bottom();
1025 d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
1026 d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
1027 if (hints & QDrawBorderPixmap::OpaqueBottomLeft)
1028 opaqueData.append(d);
1029 else
1030 translucentData.append(d);
1031 }
1032 if (targetMargins.bottom() > 0 && targetMargins.right() > 0 && sourceMargins.bottom() > 0 && sourceMargins.right() > 0) { // bottom right
1033 d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
1034 d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1]));
1035 d.sourceLeft = sourceCenterRight;
1036 d.sourceTop = sourceCenterBottom;
1037 d.width = sourceMargins.right();
1038 d.height = sourceMargins.bottom();
1039 d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
1040 d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
1041 if (hints & QDrawBorderPixmap::OpaqueBottomRight)
1042 opaqueData.append(d);
1043 else
1044 translucentData.append(d);
1045 }
1046
1047 // horizontal edges
1048 if (targetCenterWidth > 0 && sourceCenterWidth > 0) {
1049 if (targetMargins.top() > 0 && sourceMargins.top() > 0) { // top
1050 QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueTop ? opaqueData : translucentData;
1051 d.sourceLeft = sourceCenterLeft;
1052 d.sourceTop = sourceRect.top();
1053 d.width = sourceCenterWidth;
1054 d.height = sourceMargins.top();
1055 d.y = (0.5 * (yTarget[1] + yTarget[0]));
1056 d.scaleX = dx / d.width;
1057 d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
1058 for (int i = 1; i < columns - 1; ++i) {
1059 d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
1060 data.append(d);
1061 }
1062 if (rules.horizontal == Qt::RepeatTile)
1063 data[data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX);
1064 }
1065 if (targetMargins.bottom() > 0 && sourceMargins.bottom() > 0) { // bottom
1066 QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueBottom ? opaqueData : translucentData;
1067 d.sourceLeft = sourceCenterLeft;
1068 d.sourceTop = sourceCenterBottom;
1069 d.width = sourceCenterWidth;
1070 d.height = sourceMargins.bottom();
1071 d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1]));
1072 d.scaleX = dx / d.width;
1073 d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
1074 for (int i = 1; i < columns - 1; ++i) {
1075 d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
1076 data.append(d);
1077 }
1078 if (rules.horizontal == Qt::RepeatTile)
1079 data[data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX);
1080 }
1081 }
1082
1083 // vertical edges
1084 if (targetCenterHeight > 0 && sourceCenterHeight > 0) {
1085 if (targetMargins.left() > 0 && sourceMargins.left() > 0) { // left
1086 QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueLeft ? opaqueData : translucentData;
1087 d.sourceLeft = sourceRect.left();
1088 d.sourceTop = sourceCenterTop;
1089 d.width = sourceMargins.left();
1090 d.height = sourceCenterHeight;
1091 d.x = (0.5 * (xTarget[1] + xTarget[0]));
1092 d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
1093 d.scaleY = dy / d.height;
1094 for (int i = 1; i < rows - 1; ++i) {
1095 d.y = (0.5 * (yTarget[i + 1] + yTarget[i]));
1096 data.append(d);
1097 }
1098 if (rules.vertical == Qt::RepeatTile)
1099 data[data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY);
1100 }
1101 if (targetMargins.right() > 0 && sourceMargins.right() > 0) { // right
1102 QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueRight ? opaqueData : translucentData;
1103 d.sourceLeft = sourceCenterRight;
1104 d.sourceTop = sourceCenterTop;
1105 d.width = sourceMargins.right();
1106 d.height = sourceCenterHeight;
1107 d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
1108 d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
1109 d.scaleY = dy / d.height;
1110 for (int i = 1; i < rows - 1; ++i) {
1111 d.y = (0.5 * (yTarget[i + 1] + yTarget[i]));
1112 data.append(d);
1113 }
1114 if (rules.vertical == Qt::RepeatTile)
1115 data[data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY);
1116 }
1117 }
1118
1119 // center
1120 if (targetCenterWidth > 0 && targetCenterHeight > 0 && sourceCenterWidth > 0 && sourceCenterHeight > 0) {
1121 QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueCenter ? opaqueData : translucentData;
1122 d.sourceLeft = sourceCenterLeft;
1123 d.sourceTop = sourceCenterTop;
1124 d.width = sourceCenterWidth;
1125 d.height = sourceCenterHeight;
1126 d.scaleX = dx / d.width;
1127 d.scaleY = dy / d.height;
1128
1129 qreal repeatWidth = (xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX;
1130 qreal repeatHeight = (yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY;
1131
1132 for (int j = 1; j < rows - 1; ++j) {
1133 d.y = (0.5 * (yTarget[j + 1] + yTarget[j]));
1134 for (int i = 1; i < columns - 1; ++i) {
1135 d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
1136 data.append(d);
1137 }
1138 if (rules.horizontal == Qt::RepeatTile)
1139 data[data.size() - 1].width = repeatWidth;
1140 }
1141 if (rules.vertical == Qt::RepeatTile) {
1142 for (int i = 1; i < columns - 1; ++i)
1143 data[data.size() - i].height = repeatHeight;
1144 }
1145 }
1146
1147 if (opaqueData.size())
1148 painter->drawPixmapFragments(opaqueData.data(), opaqueData.size(), pixmap, QPainter::OpaqueHint);
1149 if (translucentData.size())
1150 painter->drawPixmapFragments(translucentData.data(), translucentData.size(), pixmap);
1151
1152 if (oldAA)
1153 painter->setRenderHint(QPainter::Antialiasing, true);
1154}
1155
1156QT_END_NAMESPACE
friend class QPainter
\inmodule QtCore\reentrant
Definition qpoint.h:29
static void qDrawWinShades(QPainter *p, int x, int y, int w, int h, const QColor &c1, const QColor &c2, const QColor &c3, const QColor &c4, const QBrush *fill)
QVarLengthArray< QPainter::PixmapFragment, 16 > QPixmapFragmentsArray
Q_WIDGETS_EXPORT void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &, int lineWidth=1, const QBrush *fill=nullptr)
Q_WIDGETS_EXPORT void qDrawShadeRect(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken=false, int lineWidth=1, int midLineWidth=0, const QBrush *fill=nullptr)
Q_WIDGETS_EXPORT void qDrawWinPanel(QPainter *p, const QRect &r, const QPalette &pal, bool sunken=false, const QBrush *fill=nullptr)
Q_WIDGETS_EXPORT void qDrawShadePanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken=false, int lineWidth=1, const QBrush *fill=nullptr)
Q_WIDGETS_EXPORT void qDrawWinButton(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken=false, const QBrush *fill=nullptr)
Q_WIDGETS_EXPORT void qDrawShadeRect(QPainter *p, const QRect &r, const QPalette &pal, bool sunken=false, int lineWidth=1, int midLineWidth=0, const QBrush *fill=nullptr)
Q_WIDGETS_EXPORT void qDrawWinButton(QPainter *p, const QRect &r, const QPalette &pal, bool sunken=false, const QBrush *fill=nullptr)
Q_WIDGETS_EXPORT void qDrawPlainRect(QPainter *p, const QRect &r, const QColor &, int lineWidth=1, const QBrush *fill=nullptr)
Q_WIDGETS_EXPORT void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint &p2, const QPalette &pal, bool sunken=true, int lineWidth=1, int midLineWidth=0)
Q_WIDGETS_EXPORT void qDrawShadePanel(QPainter *p, const QRect &r, const QPalette &pal, bool sunken=false, int lineWidth=1, const QBrush *fill=nullptr)
Q_WIDGETS_EXPORT void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2, const QPalette &pal, bool sunken=true, int lineWidth=1, int midLineWidth=0)
Definition qdrawutil.cpp:60
Q_WIDGETS_EXPORT void qDrawPlainRoundedRect(QPainter *p, int x, int y, int w, int h, qreal rx, qreal ry, const QColor &, int lineWidth=1, const QBrush *fill=nullptr)
Q_WIDGETS_EXPORT void qDrawWinPanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken=false, const QBrush *fill=nullptr)
The QTileRules class provides the rules used to draw a pixmap or image split into nine segments.
Definition qdrawutil.h:89