QtBase  v6.3.1
qpainter.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #ifndef QPAINTER_H
41 #define QPAINTER_H
42 
43 #include <QtGui/qtguiglobal.h>
44 #include <QtCore/qnamespace.h>
45 #include <QtCore/qrect.h>
46 #include <QtCore/qpoint.h>
47 #include <QtCore/qscopedpointer.h>
48 #include <QtGui/qpixmap.h>
49 #include <QtGui/qimage.h>
50 #include <QtGui/qtextoption.h>
51 #include <memory>
52 
53 #ifndef QT_INCLUDE_COMPAT
54 #include <QtGui/qpolygon.h>
55 #include <QtGui/qpen.h>
56 #include <QtGui/qbrush.h>
57 #include <QtGui/qtransform.h>
58 #include <QtGui/qfontinfo.h>
59 #include <QtGui/qfontmetrics.h>
60 #endif
61 
63 
64 
65 class QBrush;
66 class QFontInfo;
67 class QFontMetrics;
68 class QPaintDevice;
69 class QPainterPath;
70 class QPainterPrivate;
71 class QPen;
72 class QPolygon;
73 class QTextItem;
74 class QTextEngine;
75 class QTransform;
76 class QStaticText;
77 class QGlyphRun;
78 
79 class QPainterPrivateDeleter;
80 
81 class Q_GUI_EXPORT QPainter
82 {
83  Q_DECLARE_PRIVATE(QPainter)
84  Q_GADGET
85 
86 public:
87  enum RenderHint {
88  Antialiasing = 0x01,
89  TextAntialiasing = 0x02,
90  SmoothPixmapTransform = 0x04,
91  VerticalSubpixelPositioning = 0x08,
92  LosslessImageRendering = 0x40,
93  };
94  Q_ENUM(RenderHint)
95 
96  Q_DECLARE_FLAGS(RenderHints, RenderHint)
97  Q_FLAG(RenderHints)
98 
100  public:
111  static PixmapFragment Q_GUI_EXPORT create(const QPointF &pos, const QRectF &sourceRect,
112  qreal scaleX = 1, qreal scaleY = 1,
113  qreal rotation = 0, qreal opacity = 1);
114  };
115 
117  OpaqueHint = 0x01
118  };
119 
120  Q_DECLARE_FLAGS(PixmapFragmentHints, PixmapFragmentHint)
121 
122  QPainter();
123  explicit QPainter(QPaintDevice *);
124  ~QPainter();
125 
126  QPaintDevice *device() const;
127 
128  bool begin(QPaintDevice *);
129  bool end();
130  bool isActive() const;
131 
145 
146  //svg 1.2 blend modes
159 
160  // ROPs
174  RasterOp_NotDestination
175  };
176  void setCompositionMode(CompositionMode mode);
177  CompositionMode compositionMode() const;
178 
179  const QFont &font() const;
180  void setFont(const QFont &f);
181 
182  QFontMetrics fontMetrics() const;
183  QFontInfo fontInfo() const;
184 
185  void setPen(const QColor &color);
186  void setPen(const QPen &pen);
187  void setPen(Qt::PenStyle style);
188  const QPen &pen() const;
189 
190  void setBrush(const QBrush &brush);
191  void setBrush(Qt::BrushStyle style);
192  const QBrush &brush() const;
193 
194  // attributes/modes
195  void setBackgroundMode(Qt::BGMode mode);
196  Qt::BGMode backgroundMode() const;
197 
198  QPoint brushOrigin() const;
199  inline void setBrushOrigin(int x, int y);
200  inline void setBrushOrigin(const QPoint &);
201  void setBrushOrigin(const QPointF &);
202 
203  void setBackground(const QBrush &bg);
204  const QBrush &background() const;
205 
206  qreal opacity() const;
207  void setOpacity(qreal opacity);
208 
209  // Clip functions
210  QRegion clipRegion() const;
211  QPainterPath clipPath() const;
212 
213  void setClipRect(const QRectF &, Qt::ClipOperation op = Qt::ReplaceClip);
214  void setClipRect(const QRect &, Qt::ClipOperation op = Qt::ReplaceClip);
215  inline void setClipRect(int x, int y, int w, int h, Qt::ClipOperation op = Qt::ReplaceClip);
216 
217  void setClipRegion(const QRegion &, Qt::ClipOperation op = Qt::ReplaceClip);
218 
219  void setClipPath(const QPainterPath &path, Qt::ClipOperation op = Qt::ReplaceClip);
220 
221  void setClipping(bool enable);
222  bool hasClipping() const;
223 
224  QRectF clipBoundingRect() const;
225 
226  void save();
227  void restore();
228 
229  // XForm functions
230  void setTransform(const QTransform &transform, bool combine = false);
231  const QTransform &transform() const;
232  const QTransform &deviceTransform() const;
233  void resetTransform();
234 
235  void setWorldTransform(const QTransform &matrix, bool combine = false);
236  const QTransform &worldTransform() const;
237 
238  QTransform combinedTransform() const;
239 
240  void setWorldMatrixEnabled(bool enabled);
241  bool worldMatrixEnabled() const;
242 
243  void scale(qreal sx, qreal sy);
244  void shear(qreal sh, qreal sv);
245  void rotate(qreal a);
246 
247  void translate(const QPointF &offset);
248  inline void translate(const QPoint &offset);
249  inline void translate(qreal dx, qreal dy);
250 
251  QRect window() const;
252  void setWindow(const QRect &window);
253  inline void setWindow(int x, int y, int w, int h);
254 
255  QRect viewport() const;
256  void setViewport(const QRect &viewport);
257  inline void setViewport(int x, int y, int w, int h);
258 
259  void setViewTransformEnabled(bool enable);
260  bool viewTransformEnabled() const;
261 
262  // drawing functions
263  void strokePath(const QPainterPath &path, const QPen &pen);
264  void fillPath(const QPainterPath &path, const QBrush &brush);
265  void drawPath(const QPainterPath &path);
266 
267  inline void drawPoint(const QPointF &pt);
268  inline void drawPoint(const QPoint &p);
269  inline void drawPoint(int x, int y);
270 
271  void drawPoints(const QPointF *points, int pointCount);
272  inline void drawPoints(const QPolygonF &points);
273  void drawPoints(const QPoint *points, int pointCount);
274  inline void drawPoints(const QPolygon &points);
275 
276  inline void drawLine(const QLineF &line);
277  inline void drawLine(const QLine &line);
278  inline void drawLine(int x1, int y1, int x2, int y2);
279  inline void drawLine(const QPoint &p1, const QPoint &p2);
280  inline void drawLine(const QPointF &p1, const QPointF &p2);
281 
282  void drawLines(const QLineF *lines, int lineCount);
283  inline void drawLines(const QList<QLineF> &lines);
284  void drawLines(const QPointF *pointPairs, int lineCount);
285  inline void drawLines(const QList<QPointF> &pointPairs);
286  void drawLines(const QLine *lines, int lineCount);
287  inline void drawLines(const QList<QLine> &lines);
288  void drawLines(const QPoint *pointPairs, int lineCount);
289  inline void drawLines(const QList<QPoint> &pointPairs);
290 
291  inline void drawRect(const QRectF &rect);
292  inline void drawRect(int x1, int y1, int w, int h);
293  inline void drawRect(const QRect &rect);
294 
295  void drawRects(const QRectF *rects, int rectCount);
296  inline void drawRects(const QList<QRectF> &rectangles);
297  void drawRects(const QRect *rects, int rectCount);
298  inline void drawRects(const QList<QRect> &rectangles);
299 
300  void drawEllipse(const QRectF &r);
301  void drawEllipse(const QRect &r);
302  inline void drawEllipse(int x, int y, int w, int h);
303 
304  inline void drawEllipse(const QPointF &center, qreal rx, qreal ry);
305  inline void drawEllipse(const QPoint &center, int rx, int ry);
306 
307  void drawPolyline(const QPointF *points, int pointCount);
308  inline void drawPolyline(const QPolygonF &polyline);
309  void drawPolyline(const QPoint *points, int pointCount);
310  inline void drawPolyline(const QPolygon &polygon);
311 
312  void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule = Qt::OddEvenFill);
313  inline void drawPolygon(const QPolygonF &polygon, Qt::FillRule fillRule = Qt::OddEvenFill);
314  void drawPolygon(const QPoint *points, int pointCount, Qt::FillRule fillRule = Qt::OddEvenFill);
315  inline void drawPolygon(const QPolygon &polygon, Qt::FillRule fillRule = Qt::OddEvenFill);
316 
317  void drawConvexPolygon(const QPointF *points, int pointCount);
318  inline void drawConvexPolygon(const QPolygonF &polygon);
319  void drawConvexPolygon(const QPoint *points, int pointCount);
320  inline void drawConvexPolygon(const QPolygon &polygon);
321 
322  void drawArc(const QRectF &rect, int a, int alen);
323  inline void drawArc(const QRect &, int a, int alen);
324  inline void drawArc(int x, int y, int w, int h, int a, int alen);
325 
326  void drawPie(const QRectF &rect, int a, int alen);
327  inline void drawPie(int x, int y, int w, int h, int a, int alen);
328  inline void drawPie(const QRect &, int a, int alen);
329 
330  void drawChord(const QRectF &rect, int a, int alen);
331  inline void drawChord(int x, int y, int w, int h, int a, int alen);
332  inline void drawChord(const QRect &, int a, int alen);
333 
334  void drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius,
336  inline void drawRoundedRect(int x, int y, int w, int h, qreal xRadius, qreal yRadius,
338  inline void drawRoundedRect(const QRect &rect, qreal xRadius, qreal yRadius,
340 
341  void drawTiledPixmap(const QRectF &rect, const QPixmap &pm, const QPointF &offset = QPointF());
342  inline void drawTiledPixmap(int x, int y, int w, int h, const QPixmap &, int sx=0, int sy=0);
343  inline void drawTiledPixmap(const QRect &, const QPixmap &, const QPoint & = QPoint());
344 #ifndef QT_NO_PICTURE
345  void drawPicture(const QPointF &p, const QPicture &picture);
346  inline void drawPicture(int x, int y, const QPicture &picture);
347  inline void drawPicture(const QPoint &p, const QPicture &picture);
348 #endif
349 
350  void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect);
351  inline void drawPixmap(const QRect &targetRect, const QPixmap &pixmap, const QRect &sourceRect);
352  inline void drawPixmap(int x, int y, int w, int h, const QPixmap &pm,
353  int sx, int sy, int sw, int sh);
354  inline void drawPixmap(int x, int y, const QPixmap &pm,
355  int sx, int sy, int sw, int sh);
356  inline void drawPixmap(const QPointF &p, const QPixmap &pm, const QRectF &sr);
357  inline void drawPixmap(const QPoint &p, const QPixmap &pm, const QRect &sr);
358  void drawPixmap(const QPointF &p, const QPixmap &pm);
359  inline void drawPixmap(const QPoint &p, const QPixmap &pm);
360  inline void drawPixmap(int x, int y, const QPixmap &pm);
361  inline void drawPixmap(const QRect &r, const QPixmap &pm);
362  inline void drawPixmap(int x, int y, int w, int h, const QPixmap &pm);
363 
364  void drawPixmapFragments(const PixmapFragment *fragments, int fragmentCount,
365  const QPixmap &pixmap, PixmapFragmentHints hints = PixmapFragmentHints());
366 
367  void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect,
368  Qt::ImageConversionFlags flags = Qt::AutoColor);
369  inline void drawImage(const QRect &targetRect, const QImage &image, const QRect &sourceRect,
370  Qt::ImageConversionFlags flags = Qt::AutoColor);
371  inline void drawImage(const QPointF &p, const QImage &image, const QRectF &sr,
372  Qt::ImageConversionFlags flags = Qt::AutoColor);
373  inline void drawImage(const QPoint &p, const QImage &image, const QRect &sr,
374  Qt::ImageConversionFlags flags = Qt::AutoColor);
375  inline void drawImage(const QRectF &r, const QImage &image);
376  inline void drawImage(const QRect &r, const QImage &image);
377  void drawImage(const QPointF &p, const QImage &image);
378  inline void drawImage(const QPoint &p, const QImage &image);
379  inline void drawImage(int x, int y, const QImage &image, int sx = 0, int sy = 0,
380  int sw = -1, int sh = -1, Qt::ImageConversionFlags flags = Qt::AutoColor);
381 
382  void setLayoutDirection(Qt::LayoutDirection direction);
383  Qt::LayoutDirection layoutDirection() const;
384 
385 #if !defined(QT_NO_RAWFONT)
386  void drawGlyphRun(const QPointF &position, const QGlyphRun &glyphRun);
387 #endif
388 
389  void drawStaticText(const QPointF &topLeftPosition, const QStaticText &staticText);
390  inline void drawStaticText(const QPoint &topLeftPosition, const QStaticText &staticText);
391  inline void drawStaticText(int left, int top, const QStaticText &staticText);
392 
393  void drawText(const QPointF &p, const QString &s);
394  inline void drawText(const QPoint &p, const QString &s);
395  inline void drawText(int x, int y, const QString &s);
396 
397  void drawText(const QPointF &p, const QString &str, int tf, int justificationPadding);
398 
399  void drawText(const QRectF &r, int flags, const QString &text, QRectF *br = nullptr);
400  void drawText(const QRect &r, int flags, const QString &text, QRect *br = nullptr);
401  inline void drawText(int x, int y, int w, int h, int flags, const QString &text, QRect *br = nullptr);
402 
403  void drawText(const QRectF &r, const QString &text, const QTextOption &o = QTextOption());
404 
405  QRectF boundingRect(const QRectF &rect, int flags, const QString &text);
406  QRect boundingRect(const QRect &rect, int flags, const QString &text);
407  inline QRect boundingRect(int x, int y, int w, int h, int flags, const QString &text);
408 
409  QRectF boundingRect(const QRectF &rect, const QString &text, const QTextOption &o = QTextOption());
410 
411  void drawTextItem(const QPointF &p, const QTextItem &ti);
412  inline void drawTextItem(int x, int y, const QTextItem &ti);
413  inline void drawTextItem(const QPoint &p, const QTextItem &ti);
414 
415  void fillRect(const QRectF &, const QBrush &);
416  inline void fillRect(int x, int y, int w, int h, const QBrush &);
417  void fillRect(const QRect &, const QBrush &);
418 
419  void fillRect(const QRectF &, const QColor &color);
420  inline void fillRect(int x, int y, int w, int h, const QColor &color);
421  void fillRect(const QRect &, const QColor &color);
422 
423  inline void fillRect(int x, int y, int w, int h, Qt::GlobalColor c);
424  inline void fillRect(const QRect &r, Qt::GlobalColor c);
425  inline void fillRect(const QRectF &r, Qt::GlobalColor c);
426 
427  inline void fillRect(int x, int y, int w, int h, Qt::BrushStyle style);
428  inline void fillRect(const QRect &r, Qt::BrushStyle style);
429  inline void fillRect(const QRectF &r, Qt::BrushStyle style);
430 
431  inline void fillRect(int x, int y, int w, int h, QGradient::Preset preset);
432  inline void fillRect(const QRect &r, QGradient::Preset preset);
433  inline void fillRect(const QRectF &r, QGradient::Preset preset);
434 
435  void eraseRect(const QRectF &);
436  inline void eraseRect(int x, int y, int w, int h);
437  inline void eraseRect(const QRect &);
438 
439  void setRenderHint(RenderHint hint, bool on = true);
440  void setRenderHints(RenderHints hints, bool on = true);
441  RenderHints renderHints() const;
442  inline bool testRenderHint(RenderHint hint) const { return renderHints() & hint; }
443 
444  QPaintEngine *paintEngine() const;
445 
446  void beginNativePainting();
447  void endNativePainting();
448 
449 private:
451 
452  std::unique_ptr<QPainterPrivate> d_ptr;
453 
454  friend class QWidget;
455  friend class QFontEngine;
456  friend class QFontEngineBox;
457  friend class QFontEngineFT;
458  friend class QFontEngineMac;
459  friend class QFontEngineWin;
460  friend class QPaintEngine;
461  friend class QPaintEngineExPrivate;
462  friend class QOpenGLPaintEngine;
463  friend class QWin32PaintEngine;
464  friend class QWin32PaintEnginePrivate;
465  friend class QRasterPaintEngine;
466  friend class QAlphaPaintEngine;
467  friend class QPreviewPaintEngine;
468  friend class QTextEngine;
469 };
471 
472 Q_DECLARE_OPERATORS_FOR_FLAGS(QPainter::RenderHints)
473 
474 //
475 // functions
476 //
477 inline void QPainter::drawLine(const QLineF &l)
478 {
479  drawLines(&l, 1);
480 }
481 
482 inline void QPainter::drawLine(const QLine &line)
483 {
484  drawLines(&line, 1);
485 }
486 
487 inline void QPainter::drawLine(int x1, int y1, int x2, int y2)
488 {
489  QLine l(x1, y1, x2, y2);
490  drawLines(&l, 1);
491 }
492 
493 inline void QPainter::drawLine(const QPoint &p1, const QPoint &p2)
494 {
495  QLine l(p1, p2);
496  drawLines(&l, 1);
497 }
498 
499 inline void QPainter::drawLine(const QPointF &p1, const QPointF &p2)
500 {
501  drawLine(QLineF(p1, p2));
502 }
503 
505 {
506  drawLines(lines.constData(), int(lines.size()));
507 }
508 
510 {
511  drawLines(lines.constData(), int(lines.size()));
512 }
513 
514 inline void QPainter::drawLines(const QList<QPointF> &pointPairs)
515 {
516  drawLines(pointPairs.constData(), int(pointPairs.size() / 2));
517 }
518 
519 inline void QPainter::drawLines(const QList<QPoint> &pointPairs)
520 {
521  drawLines(pointPairs.constData(), int(pointPairs.size() / 2));
522 }
523 
524 inline void QPainter::drawPolyline(const QPolygonF &polyline)
525 {
526  drawPolyline(polyline.constData(), int(polyline.size()));
527 }
528 
529 inline void QPainter::drawPolyline(const QPolygon &polyline)
530 {
531  drawPolyline(polyline.constData(), int(polyline.size()));
532 }
533 
535 {
536  drawPolygon(polygon.constData(), int(polygon.size()), fillRule);
537 }
538 
539 inline void QPainter::drawPolygon(const QPolygon &polygon, Qt::FillRule fillRule)
540 {
541  drawPolygon(polygon.constData(), int(polygon.size()), fillRule);
542 }
543 
544 inline void QPainter::drawConvexPolygon(const QPolygonF &poly)
545 {
546  drawConvexPolygon(poly.constData(), int(poly.size()));
547 }
548 
549 inline void QPainter::drawConvexPolygon(const QPolygon &poly)
550 {
551  drawConvexPolygon(poly.constData(), int(poly.size()));
552 }
553 
554 inline void QPainter::drawRect(const QRectF &rect)
555 {
556  drawRects(&rect, 1);
557 }
558 
559 inline void QPainter::drawRect(int x, int y, int w, int h)
560 {
561  QRect r(x, y, w, h);
562  drawRects(&r, 1);
563 }
564 
565 inline void QPainter::drawRect(const QRect &r)
566 {
567  drawRects(&r, 1);
568 }
569 
570 inline void QPainter::drawRects(const QList<QRectF> &rects)
571 {
572  drawRects(rects.constData(), int(rects.size()));
573 }
574 
575 inline void QPainter::drawRects(const QList<QRect> &rects)
576 {
577  drawRects(rects.constData(), int(rects.size()));
578 }
579 
580 inline void QPainter::drawPoint(const QPointF &p)
581 {
582  drawPoints(&p, 1);
583 }
584 
585 inline void QPainter::drawPoint(int x, int y)
586 {
587  QPoint p(x, y);
588  drawPoints(&p, 1);
589 }
590 
591 inline void QPainter::drawPoint(const QPoint &p)
592 {
593  drawPoints(&p, 1);
594 }
595 
597 {
598  drawPoints(points.constData(), int(points.size()));
599 }
600 
602 {
603  drawPoints(points.constData(), int(points.size()));
604 }
605 
606 inline void QPainter::drawRoundedRect(int x, int y, int w, int h, qreal xRadius, qreal yRadius,
608 {
609  drawRoundedRect(QRectF(x, y, w, h), xRadius, yRadius, mode);
610 }
611 
612 inline void QPainter::drawRoundedRect(const QRect &rect, qreal xRadius, qreal yRadius,
614 {
615  drawRoundedRect(QRectF(rect), xRadius, yRadius, mode);
616 }
617 
618 inline void QPainter::drawEllipse(int x, int y, int w, int h)
619 {
620  drawEllipse(QRect(x, y, w, h));
621 }
622 
624 {
625  drawEllipse(QRectF(center.x() - rx, center.y() - ry, 2 * rx, 2 * ry));
626 }
627 
628 inline void QPainter::drawEllipse(const QPoint &center, int rx, int ry)
629 {
630  drawEllipse(QRect(center.x() - rx, center.y() - ry, 2 * rx, 2 * ry));
631 }
632 
633 inline void QPainter::drawArc(const QRect &r, int a, int alen)
634 {
635  drawArc(QRectF(r), a, alen);
636 }
637 
638 inline void QPainter::drawArc(int x, int y, int w, int h, int a, int alen)
639 {
640  drawArc(QRectF(x, y, w, h), a, alen);
641 }
642 
643 inline void QPainter::drawPie(const QRect &rect, int a, int alen)
644 {
645  drawPie(QRectF(rect), a, alen);
646 }
647 
648 inline void QPainter::drawPie(int x, int y, int w, int h, int a, int alen)
649 {
650  drawPie(QRectF(x, y, w, h), a, alen);
651 }
652 
653 inline void QPainter::drawChord(const QRect &rect, int a, int alen)
654 {
655  drawChord(QRectF(rect), a, alen);
656 }
657 
658 inline void QPainter::drawChord(int x, int y, int w, int h, int a, int alen)
659 {
660  drawChord(QRectF(x, y, w, h), a, alen);
661 }
662 
663 inline void QPainter::setClipRect(int x, int y, int w, int h, Qt::ClipOperation op)
664 {
665  setClipRect(QRect(x, y, w, h), op);
666 }
667 
668 inline void QPainter::eraseRect(const QRect &rect)
669 {
671 }
672 
673 inline void QPainter::eraseRect(int x, int y, int w, int h)
674 {
675  eraseRect(QRectF(x, y, w, h));
676 }
677 
678 inline void QPainter::fillRect(int x, int y, int w, int h, const QBrush &b)
679 {
680  fillRect(QRect(x, y, w, h), b);
681 }
682 
683 inline void QPainter::fillRect(int x, int y, int w, int h, const QColor &b)
684 {
685  fillRect(QRect(x, y, w, h), b);
686 }
687 
688 inline void QPainter::fillRect(int x, int y, int w, int h, Qt::GlobalColor c)
689 {
690  fillRect(QRect(x, y, w, h), QColor(c));
691 }
692 
694 {
695  fillRect(r, QColor(c));
696 }
697 
699 {
700  fillRect(r, QColor(c));
701 }
702 
703 inline void QPainter::fillRect(int x, int y, int w, int h, Qt::BrushStyle style)
704 {
705  fillRect(QRectF(x, y, w, h), QBrush(style));
706 }
707 
709 {
711 }
712 
714 {
715  fillRect(r, QBrush(style));
716 }
717 
718 inline void QPainter::fillRect(int x, int y, int w, int h, QGradient::Preset p)
719 {
720  fillRect(QRect(x, y, w, h), QGradient(p));
721 }
722 
724 {
725  fillRect(r, QGradient(p));
726 }
727 
729 {
730  fillRect(r, QGradient(p));
731 }
732 
733 inline void QPainter::setBrushOrigin(int x, int y)
734 {
736 }
737 
738 inline void QPainter::setBrushOrigin(const QPoint &p)
739 {
741 }
742 
743 inline void QPainter::drawTiledPixmap(const QRect &rect, const QPixmap &pm, const QPoint &offset)
744 {
746 }
747 
748 inline void QPainter::drawTiledPixmap(int x, int y, int w, int h, const QPixmap &pm, int sx, int sy)
749 {
750  drawTiledPixmap(QRectF(x, y, w, h), pm, QPointF(sx, sy));
751 }
752 
753 inline void QPainter::drawPixmap(const QRect &targetRect, const QPixmap &pixmap, const QRect &sourceRect)
754 {
755  drawPixmap(QRectF(targetRect), pixmap, QRectF(sourceRect));
756 }
757 
758 inline void QPainter::drawPixmap(const QPoint &p, const QPixmap &pm)
759 {
760  drawPixmap(QPointF(p), pm);
761 }
762 
763 inline void QPainter::drawPixmap(const QRect &r, const QPixmap &pm)
764 {
765  drawPixmap(QRectF(r), pm, QRectF());
766 }
767 
768 inline void QPainter::drawPixmap(int x, int y, const QPixmap &pm)
769 {
770  drawPixmap(QPointF(x, y), pm);
771 }
772 
773 inline void QPainter::drawPixmap(int x, int y, int w, int h, const QPixmap &pm)
774 {
775  drawPixmap(QRectF(x, y, w, h), pm, QRectF());
776 }
777 
778 inline void QPainter::drawPixmap(int x, int y, int w, int h, const QPixmap &pm,
779  int sx, int sy, int sw, int sh)
780 {
781  drawPixmap(QRectF(x, y, w, h), pm, QRectF(sx, sy, sw, sh));
782 }
783 
784 inline void QPainter::drawPixmap(int x, int y, const QPixmap &pm,
785  int sx, int sy, int sw, int sh)
786 {
787  drawPixmap(QRectF(x, y, -1, -1), pm, QRectF(sx, sy, sw, sh));
788 }
789 
790 inline void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm, const QRectF &sr)
791 {
792  drawPixmap(QRectF(p.x(), p.y(), -1, -1), pm, sr);
793 }
794 
795 inline void QPainter::drawPixmap(const QPoint &p, const QPixmap &pm, const QRect &sr)
796 {
797  drawPixmap(QRectF(p.x(), p.y(), -1, -1), pm, sr);
798 }
799 
800 inline void QPainter::drawTextItem(int x, int y, const QTextItem &ti)
801 {
802  drawTextItem(QPointF(x, y), ti);
803 }
804 
805 inline void QPainter::drawImage(const QRect &targetRect, const QImage &image, const QRect &sourceRect,
806  Qt::ImageConversionFlags flags)
807 {
808  drawImage(QRectF(targetRect), image, QRectF(sourceRect), flags);
809 }
810 
811 inline void QPainter::drawImage(const QPointF &p, const QImage &image, const QRectF &sr,
812  Qt::ImageConversionFlags flags)
813 {
814  drawImage(QRectF(p.x(), p.y(), -1, -1), image, sr, flags);
815 }
816 
817 inline void QPainter::drawImage(const QPoint &p, const QImage &image, const QRect &sr,
818  Qt::ImageConversionFlags flags)
819 {
820  drawImage(QRect(p.x(), p.y(), -1, -1), image, sr, flags);
821 }
822 
823 
824 inline void QPainter::drawImage(const QRectF &r, const QImage &image)
825 {
826  drawImage(r, image, QRect(0, 0, image.width(), image.height()));
827 }
828 
829 inline void QPainter::drawImage(const QRect &r, const QImage &image)
830 {
831  drawImage(r, image, QRectF(0, 0, image.width(), image.height()));
832 }
833 
834 inline void QPainter::drawImage(const QPoint &p, const QImage &image)
835 {
837 }
838 
839 inline void QPainter::drawImage(int x, int y, const QImage &image, int sx, int sy, int sw, int sh,
840  Qt::ImageConversionFlags flags)
841 {
842  if (sx == 0 && sy == 0 && sw == -1 && sh == -1 && flags == Qt::AutoColor)
843  drawImage(QPointF(x, y), image);
844  else
845  drawImage(QRectF(x, y, -1, -1), image, QRectF(sx, sy, sw, sh), flags);
846 }
847 
848 inline void QPainter::drawStaticText(const QPoint &p, const QStaticText &staticText)
849 {
850  drawStaticText(QPointF(p), staticText);
851 }
852 
853 inline void QPainter::drawStaticText(int x, int y, const QStaticText &staticText)
854 {
855  drawStaticText(QPointF(x, y), staticText);
856 }
857 
858 inline void QPainter::drawTextItem(const QPoint &p, const QTextItem &ti)
859 {
860  drawTextItem(QPointF(p), ti);
861 }
862 
863 inline void QPainter::drawText(const QPoint &p, const QString &s)
864 {
865  drawText(QPointF(p), s);
866 }
867 
868 inline void QPainter::drawText(int x, int y, int w, int h, int flags, const QString &str, QRect *br)
869 {
870  drawText(QRect(x, y, w, h), flags, str, br);
871 }
872 
873 inline void QPainter::drawText(int x, int y, const QString &s)
874 {
875  drawText(QPointF(x, y), s);
876 }
877 
878 inline QRect QPainter::boundingRect(int x, int y, int w, int h, int flags, const QString &text)
879 {
880  return boundingRect(QRect(x, y, w, h), flags, text);
881 }
882 
883 inline void QPainter::translate(qreal dx, qreal dy)
884 {
885  translate(QPointF(dx, dy));
886 }
887 
888 inline void QPainter::translate(const QPoint &offset)
889 {
890  translate(offset.x(), offset.y());
891 }
892 
893 inline void QPainter::setViewport(int x, int y, int w, int h)
894 {
895  setViewport(QRect(x, y, w, h));
896 }
897 
898 inline void QPainter::setWindow(int x, int y, int w, int h)
899 {
900  setWindow(QRect(x, y, w, h));
901 }
902 
903 #ifndef QT_NO_PICTURE
904 inline void QPainter::drawPicture(int x, int y, const QPicture &p)
905 {
906  drawPicture(QPoint(x, y), p);
907 }
908 
909 inline void QPainter::drawPicture(const QPoint &pt, const QPicture &p)
910 {
911  drawPicture(QPointF(pt), p);
912 }
913 #endif
914 
916 
917 #endif // QPAINTER_H
Arabic default style
Definition: afstyles.h:94
@ Antialiasing
void drawPolygon(QPaintDevice *dev, int w, int h)
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:66
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
The QFont class specifies a query for a font used for drawing text.
Definition: qfont.h:56
The QFontInfo class provides general information about fonts. \inmodule QtGui.
Definition: qfontinfo.h:51
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:56
The QGlyphRun class provides direct access to the internal glyphs in a font.
Definition: qglyphrun.h:56
The QGradient class is used in combination with QBrush to specify gradient fills.
Definition: qbrush.h:171
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:73
The QLineF class provides a two-dimensional vector using floating point precision.
Definition: qline.h:215
The QLine class provides a two-dimensional vector using integer precision.
Definition: qline.h:53
Definition: qlist.h:108
qsizetype size() const noexcept
Definition: qlist.h:414
const_pointer constData() const noexcept
Definition: qlist.h:444
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
Definition: qpaintengine.h:87
This class is used in conjunction with the QPainter::drawPixmapFragments() function to specify how a ...
Definition: qpainter.h:99
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:82
void drawPoint(const QPointF &pt)
Definition: qpainter.h:580
void drawRect(const QRectF &rect)
Definition: qpainter.h:554
void drawConvexPolygon(const QPointF *points, int pointCount)
Definition: qpainter.cpp:4747
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Definition: qpainter.cpp:2717
void drawPie(const QRectF &rect, int a, int alen)
Definition: qpainter.cpp:4175
PixmapFragmentHint
the x coordinate of center point in the target rectangle.
Definition: qpainter.h:116
void drawLine(const QLineF &line)
Definition: qpainter.h:477
void setViewport(const QRect &viewport)
Definition: qpainter.cpp:7022
void drawTextItem(const QPointF &p, const QTextItem &ti)
Definition: qpainter.cpp:6114
void drawChord(const QRectF &rect, int a, int alen)
Definition: qpainter.cpp:4244
void setBrushOrigin(int x, int y)
Definition: qpainter.h:733
void drawRects(const QRectF *rects, int rectCount)
Definition: qpainter.cpp:3287
void drawTiledPixmap(const QRectF &rect, const QPixmap &pm, const QPointF &offset=QPointF())
Definition: qpainter.cpp:6402
void drawLines(const QLineF *lines, int lineCount)
Definition: qpainter.cpp:4291
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
Definition: qpainter.cpp:5175
void drawText(const QPointF &p, const QString &s)
Definition: qpainter.cpp:5444
void drawPolyline(const QPointF *points, int pointCount)
Definition: qpainter.cpp:4459
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Definition: qpainter.cpp:4883
void drawArc(const QRectF &rect, int a, int alen)
Definition: qpainter.cpp:4113
void eraseRect(const QRectF &)
Definition: qpainter.cpp:6573
void drawEllipse(const QRectF &r)
Definition: qpainter.cpp:3986
RenderHint
Definition: qpainter.h:87
void drawPicture(const QPointF &p, const QPicture &picture)
Definition: qpainter.cpp:6532
void drawStaticText(const QPointF &topLeftPosition, const QStaticText &staticText)
Definition: qpainter.cpp:5470
void drawPoints(const QPointF *points, int pointCount)
Definition: qpainter.cpp:3447
CompositionMode
Definition: qpainter.h:132
@ CompositionMode_Xor
Definition: qpainter.h:144
@ RasterOp_SourceAndNotDestination
Definition: qpainter.h:169
@ CompositionMode_Destination
Definition: qpainter.h:137
@ RasterOp_NotSourceAndNotDestination
Definition: qpainter.h:164
@ CompositionMode_Lighten
Definition: qpainter.h:152
@ CompositionMode_ColorDodge
Definition: qpainter.h:153
@ CompositionMode_DestinationAtop
Definition: qpainter.h:143
@ CompositionMode_SourceOver
Definition: qpainter.h:133
@ RasterOp_SourceOrNotDestination
Definition: qpainter.h:171
@ RasterOp_NotSourceOrNotDestination
Definition: qpainter.h:165
@ RasterOp_SourceXorDestination
Definition: qpainter.h:163
@ CompositionMode_DestinationOut
Definition: qpainter.h:141
@ CompositionMode_Clear
Definition: qpainter.h:135
@ CompositionMode_SourceAtop
Definition: qpainter.h:142
@ CompositionMode_Plus
Definition: qpainter.h:147
@ RasterOp_NotSourceAndDestination
Definition: qpainter.h:168
@ CompositionMode_Overlay
Definition: qpainter.h:150
@ RasterOp_SourceOrDestination
Definition: qpainter.h:161
@ RasterOp_ClearDestination
Definition: qpainter.h:172
@ RasterOp_NotSourceOrDestination
Definition: qpainter.h:170
@ CompositionMode_Multiply
Definition: qpainter.h:148
@ CompositionMode_Darken
Definition: qpainter.h:151
@ CompositionMode_DestinationOver
Definition: qpainter.h:134
@ RasterOp_NotSource
Definition: qpainter.h:167
@ CompositionMode_HardLight
Definition: qpainter.h:155
@ CompositionMode_Exclusion
Definition: qpainter.h:158
@ CompositionMode_Source
Definition: qpainter.h:136
@ CompositionMode_ColorBurn
Definition: qpainter.h:154
@ RasterOp_NotSourceXorDestination
Definition: qpainter.h:166
@ CompositionMode_Difference
Definition: qpainter.h:157
@ CompositionMode_SoftLight
Definition: qpainter.h:156
@ CompositionMode_DestinationIn
Definition: qpainter.h:139
@ CompositionMode_Screen
Definition: qpainter.h:149
@ CompositionMode_SourceOut
Definition: qpainter.h:140
@ RasterOp_SourceAndDestination
Definition: qpainter.h:162
@ CompositionMode_SourceIn
Definition: qpainter.h:138
@ RasterOp_SetDestination
Definition: qpainter.h:173
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
Definition: qpainter.cpp:4575
void translate(const QPointF &offset)
Definition: qpainter.cpp:2993
void fillRect(const QRectF &, const QBrush &)
Definition: qpainter.cpp:6644
void setWindow(const QRect &window)
Definition: qpainter.cpp:6958
void drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode=Qt::AbsoluteSize)
Definition: qpainter.cpp:3924
QRectF boundingRect(const QRectF &rect, int flags, const QString &text)
Definition: qpainter.cpp:6345
bool testRenderHint(RenderHint hint) const
Definition: qpainter.h:442
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:65
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:61
The QPicture class is a paint device that records and replays QPainter commands.
Definition: qpicture.h:55
The QPixmap class is an off-screen image representation that can be used as a paint device.
Definition: qpixmap.h:63
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:242
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:52
The QPolygonF class provides a list of points using floating point precision. \inmodule QtGui.
Definition: qpolygon.h:128
The QPolygon class provides a list of points using integer precision. \inmodule QtGui.
Definition: qpolygon.h:57
The QRasterPaintEngine class enables hardware acceleration of painting operations in Qt for Embedded ...
The QRectF class defines a finite rectangle in the plane using floating point precision.
Definition: qrect.h:511
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:59
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:63
The QStaticText class enables optimized drawing of text when the text and its layout is updated rarel...
Definition: qstatictext.h:57
The QString class provides a Unicode character string.
Definition: qstring.h:388
QScriptLineArray lines
The QTextItem class provides all the information required to draw text in a custom paint engine.
Definition: qpaintengine.h:64
The QTextOption class provides a description of general rich text properties. \inmodule QtGui.
Definition: qtextoption.h:54
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:56
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:133
float rotation
float rx
QString str
[2]
QPixmap p2
paint drawText(0, 50, "Hi")
QPixmap p1
[0]
QString text
[meta data]
rect
[4]
direction
fontMetrics
auto it unsigned count const
Definition: hb-iter.hh:848
#define inline
Definition: md4c.c:45
QHighDpiScaling::Point position(T, QHighDpiScaling::Point::Kind)
@ AutoColor
Definition: qnamespace.h:503
SizeMode
Definition: qnamespace.h:1161
@ AbsoluteSize
Definition: qnamespace.h:1162
ClipOperation
Definition: qnamespace.h:1330
@ ReplaceClip
Definition: qnamespace.h:1332
LayoutDirection
Definition: qnamespace.h:1462
BGMode
Definition: qnamespace.h:531
GlobalColor
Definition: qnamespace.h:58
PenStyle
Definition: qnamespace.h:1111
BrushStyle
Definition: qnamespace.h:1139
FillRule
Definition: qnamespace.h:1320
@ OddEvenFill
Definition: qnamespace.h:1321
QTextStream & center(QTextStream &stream)
Definition: brush.cpp:52
Definition: image.cpp:51
QRectF fillRect(QRect rect, int background)
set set set set set set set macro pixldst1 op
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition: qflags.h:210
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition: qflags.h:227
QT_END_INCLUDE_NAMESPACE typedef double qreal
Definition: qglobal.h:341
#define Q_DISABLE_COPY(Class)
Definition: qglobal.h:515
@ text
GLboolean GLboolean GLboolean b
GLint GLint GLint GLint GLint x
[0]
GLenum mode
GLboolean r
[2]
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint GLfloat GLfloat GLfloat GLfloat y1
GLuint GLuint end
GLuint GLfloat GLfloat GLfloat x1
GLdouble GLdouble GLdouble GLdouble top
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLfloat GLfloat f
GLuint color
[2]
GLint left
GLbitfield flags
GLboolean enable
GLenum GLuint GLintptr offset
GLint y
GLfloat GLfloat GLfloat GLfloat h
GLuint GLenum GLenum transform
Definition: qopenglext.h:11564
GLfixed GLfixed GLint GLint GLfixed points
Definition: qopenglext.h:5206
const GLubyte * c
Definition: qopenglext.h:12701
GLfixed GLfixed GLfixed y2
Definition: qopenglext.h:5231
GLuint GLenum matrix
Definition: qopenglext.h:11564
GLfixed GLfixed x2
Definition: qopenglext.h:5231
GLsizei const GLchar *const * path
Definition: qopenglext.h:4283
GLdouble s
[6]
Definition: qopenglext.h:235
GLfloat GLfloat p
[1]
Definition: qopenglext.h:12698
GLenum GLenum GLenum GLenum GLenum scale
Definition: qopenglext.h:10817
Q_DECLARE_TYPEINFO(QPainter::PixmapFragment, Q_RELOCATABLE_TYPE)
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
#define Q_ENUM(x)
Definition: qtmetamacros.h:104
#define Q_FLAG(x)
Definition: qtmetamacros.h:105
#define Q_GADGET
Definition: qtmetamacros.h:193
@ Q_RELOCATABLE_TYPE
Definition: qtypeinfo.h:156
p drawImage(offset, thumbnail)
p ry()++
item setTransform(QTransform().translate(x, y).rotate(45).translate(-x, -y))
view viewport() -> scroll(dx, dy, deviceRect)
rect deviceTransform(view->viewportTransform()).map(QPointF(0
rect rect item rotate(45)
[5]
view setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform)
widget render & pixmap
setFont(font)
aWidget window() -> setWindowTitle("New Window Title")
[2]
view create()