8#include <QtGui/qtguiglobal.h>
9#include <QtCore/qnamespace.h>
10#include <QtCore/qrect.h>
11#include <QtCore/qpoint.h>
12#include <QtCore/qscopedpointer.h>
13#include <QtGui/qpixmap.h>
14#include <QtGui/qimage.h>
15#include <QtGui/qtextoption.h>
18#ifndef QT_INCLUDE_COMPAT
19#include <QtGui/qpolygon.h>
20#include <QtGui/qpen.h>
21#include <QtGui/qbrush.h>
22#include <QtGui/qtransform.h>
23#include <QtGui/qfontinfo.h>
24#include <QtGui/qfontmetrics.h>
44class QPainterPrivateDeleter;
48 Q_DECLARE_PRIVATE(QPainter)
54 TextAntialiasing = 0x02,
55 SmoothPixmapTransform = 0x04,
56 VerticalSubpixelPositioning = 0x08,
57 LosslessImageRendering = 0x40,
58 NonCosmeticBrushPatterns = 0x80
62 Q_DECLARE_FLAGS(RenderHints, RenderHint)
65 class PixmapFragment {
77 static PixmapFragment Q_GUI_EXPORT create(
const QPointF &pos,
const QRectF &sourceRect,
78 qreal scaleX = 1, qreal scaleY = 1,
79 qreal rotation = 0, qreal opacity = 1);
86 Q_DECLARE_FLAGS(PixmapFragmentHints, PixmapFragmentHint)
92 QPaintDevice *
device()
const;
94 bool begin(QPaintDevice *);
153 void setPen(
const QColor &color);
154 QT_GUI_INLINE_SINCE(6, 11)
156 void setPen(QPen &&pen) { doSetPen(pen, &pen); }
157 void setPen(Qt::PenStyle style);
158 const QPen &
pen()
const;
160 QT_GUI_INLINE_SINCE(6, 11)
162 void setBrush(QBrush &&brush) { doSetBrush(brush, &brush); }
163 void setBrush(Qt::BrushStyle style);
165 void setBrush(Qt::GlobalColor color) { setBrush(QColor(color)); }
166 const QBrush &
brush()
const;
175 inline void setBrushOrigin(
const QPoint &);
176 void setBrushOrigin(
const QPointF &);
188 void setClipRect(
const QRectF &, Qt::ClipOperation op = Qt::ReplaceClip);
189 void setClipRect(
const QRect &, Qt::ClipOperation op = Qt::ReplaceClip);
205 void setTransform(
const QTransform &transform,
bool combine =
false);
218 void scale(qreal sx, qreal sy);
219 void shear(qreal sh, qreal sv);
222 void translate(
const QPointF &offset);
223 inline void translate(
const QPoint &offset);
224 inline void translate(qreal dx, qreal dy);
227 void setWindow(
const QRect &window);
228 inline void setWindow(
int x,
int y,
int w,
int h);
231 void setViewport(
const QRect &viewport);
232 inline void setViewport(
int x,
int y,
int w,
int h);
238 void strokePath(
const QPainterPath &path,
const QPen &pen);
239 void fillPath(
const QPainterPath &path,
const QBrush &brush);
240 void drawPath(
const QPainterPath &path);
242 inline void drawPoint(
const QPointF &pt);
243 inline void drawPoint(
const QPoint &p);
247 inline void drawPoints(
const QPolygonF &points);
248 void drawPoints(
const QPoint *points,
int pointCount);
251 inline void drawLine(
const QLineF &line);
252 inline void drawLine(
const QLine &line);
253 inline void drawLine(
int x1,
int y1,
int x2,
int y2);
254 inline void drawLine(
const QPoint &p1,
const QPoint &p2);
257 void drawLines(
const QLineF *lines,
int lineCount);
258 inline void drawLines(
const QList<QLineF> &lines);
259 void drawLines(
const QPointF *pointPairs,
int lineCount);
260 inline void drawLines(
const QList<QPointF> &pointPairs);
261 void drawLines(
const QLine *lines,
int lineCount);
262 inline void drawLines(
const QList<QLine> &lines);
263 void drawLines(
const QPoint *pointPairs,
int lineCount);
264 inline void drawLines(
const QList<QPoint> &pointPairs);
266 inline void drawRect(
const QRectF &rect);
267 inline void drawRect(
int x1,
int y1,
int w,
int h);
268 inline void drawRect(
const QRect &rect);
270 void drawRects(
const QRectF *rects,
int rectCount);
271 inline void drawRects(
const QList<QRectF> &rectangles);
272 void drawRects(
const QRect *rects,
int rectCount);
273 inline void drawRects(
const QList<QRect> &rectangles);
276 void drawEllipse(
const QRect &r);
277 inline void drawEllipse(
int x,
int y,
int w,
int h);
279 inline void drawEllipse(
const QPointF ¢er, qreal rx, qreal ry);
280 inline void drawEllipse(
const QPoint ¢er,
int rx,
int ry);
282 void drawPolyline(
const QPointF *points,
int pointCount);
284 void drawPolyline(
const QPoint *points,
int pointCount);
287 void drawPolygon(
const QPointF *points,
int pointCount, Qt::FillRule fillRule = Qt::OddEvenFill);
289 void drawPolygon(
const QPoint *points,
int pointCount, Qt::FillRule fillRule = Qt::OddEvenFill);
292 void drawConvexPolygon(
const QPointF *points,
int pointCount);
294 void drawConvexPolygon(
const QPoint *points,
int pointCount);
297 void drawArc(
const QRectF &rect,
int a,
int alen);
298 inline void drawArc(
const QRect &,
int a,
int alen);
299 inline void drawArc(
int x,
int y,
int w,
int h,
int a,
int alen);
301 void drawPie(
const QRectF &rect,
int a,
int alen);
302 inline void drawPie(
int x,
int y,
int w,
int h,
int a,
int alen);
303 inline void drawPie(
const QRect &,
int a,
int alen);
305 void drawChord(
const QRectF &rect,
int a,
int alen);
306 inline void drawChord(
int x,
int y,
int w,
int h,
int a,
int alen);
307 inline void drawChord(
const QRect &,
int a,
int alen);
309 void drawRoundedRect(
const QRectF &rect, qreal xRadius, qreal yRadius,
310 Qt::SizeMode mode = Qt::AbsoluteSize);
311 inline void drawRoundedRect(
int x,
int y,
int w,
int h, qreal xRadius, qreal yRadius,
313 inline void drawRoundedRect(
const QRect &rect, qreal xRadius, qreal yRadius,
314 Qt::SizeMode mode = Qt::AbsoluteSize);
316 void drawTiledPixmap(
const QRectF &rect,
const QPixmap &pm,
const QPointF &offset = QPointF());
317 inline void drawTiledPixmap(
int x,
int y,
int w,
int h,
const QPixmap &,
int sx=0,
int sy=0);
318 inline void drawTiledPixmap(
const QRect &,
const QPixmap &,
const QPoint & = QPoint());
320 void drawPicture(
const QPointF &p,
const QPicture &picture);
321 inline void drawPicture(
int x,
int y,
const QPicture &picture);
322 inline void drawPicture(
const QPoint &p,
const QPicture &picture);
325 void drawPixmap(
const QRectF &targetRect,
const QPixmap &pixmap,
const QRectF &sourceRect);
326 inline void drawPixmap(
const QRect &targetRect,
const QPixmap &pixmap,
const QRect &sourceRect);
327 inline void drawPixmap(
int x,
int y,
int w,
int h,
const QPixmap &pm,
328 int sx,
int sy,
int sw,
int sh);
329 inline void drawPixmap(
int x,
int y,
const QPixmap &pm,
330 int sx,
int sy,
int sw,
int sh);
331 inline void drawPixmap(
const QPointF &p,
const QPixmap &pm,
const QRectF &sr);
332 inline void drawPixmap(
const QPoint &p,
const QPixmap &pm,
const QRect &sr);
333 void drawPixmap(
const QPointF &p,
const QPixmap &pm);
334 inline void drawPixmap(
const QPoint &p,
const QPixmap &pm);
335 inline void drawPixmap(
int x,
int y,
const QPixmap &pm);
336 inline void drawPixmap(
const QRect &r,
const QPixmap &pm);
337 inline void drawPixmap(
int x,
int y,
int w,
int h,
const QPixmap &pm);
339 void drawPixmapFragments(
const PixmapFragment *fragments,
int fragmentCount,
340 const QPixmap &pixmap, PixmapFragmentHints hints = PixmapFragmentHints());
342 void drawImage(
const QRectF &targetRect,
const QImage &image,
const QRectF &sourceRect,
344 inline void drawImage(
const QRect &targetRect,
const QImage &image,
const QRect &sourceRect,
345 Qt::ImageConversionFlags flags = Qt::AutoColor);
346 inline void drawImage(
const QPointF &p,
const QImage &image,
const QRectF &sr,
347 Qt::ImageConversionFlags flags = Qt::AutoColor);
348 inline void drawImage(
const QPoint &p,
const QImage &image,
const QRect &sr,
349 Qt::ImageConversionFlags flags = Qt::AutoColor);
350 inline void drawImage(
const QRectF &r,
const QImage &image);
351 inline void drawImage(
const QRect &r,
const QImage &image);
352 void drawImage(
const QPointF &p,
const QImage &image);
353 inline void drawImage(
const QPoint &p,
const QImage &image);
354 inline void drawImage(
int x,
int y,
const QImage &image,
int sx = 0,
int sy = 0,
355 int sw = -1,
int sh = -1, Qt::ImageConversionFlags flags =
Qt::
AutoColor);
360#if !defined(QT_NO_RAWFONT)
361 void drawGlyphRun(
const QPointF &position,
const QGlyphRun &glyphRun);
364 void drawStaticText(
const QPointF &topLeftPosition,
const QStaticText &staticText);
365 inline void drawStaticText(
const QPoint &topLeftPosition,
const QStaticText &staticText);
366 inline void drawStaticText(
int left,
int top,
const QStaticText &staticText);
368 void drawText(
const QPointF &p,
const QString &s);
369 inline void drawText(
const QPoint &p,
const QString &s);
370 inline void drawText(
int x,
int y,
const QString &s);
372 void drawText(
const QPointF &p,
const QString &str,
int tf,
int justificationPadding);
374 void drawText(
const QRectF &r,
int flags,
const QString &text, QRectF *br =
nullptr);
375 void drawText(
const QRect &r,
int flags,
const QString &text, QRect *br =
nullptr);
376 inline void drawText(
int x,
int y,
int w,
int h,
int flags,
const QString &text, QRect *br =
nullptr);
378 void drawText(
const QRectF &r,
const QString &text,
const QTextOption &o = QTextOption());
380 QRectF boundingRect(
const QRectF &rect,
int flags,
const QString &text);
381 QRect boundingRect(
const QRect &rect,
int flags,
const QString &text);
382 inline QRect
boundingRect(
int x,
int y,
int w,
int h,
int flags,
const QString &text);
384 QRectF boundingRect(
const QRectF &rect,
const QString &text,
const QTextOption &o = QTextOption());
386 void drawTextItem(
const QPointF &p,
const QTextItem &ti);
387 inline void drawTextItem(
int x,
int y,
const QTextItem &ti);
388 inline void drawTextItem(
const QPoint &p,
const QTextItem &ti);
390 void fillRect(
const QRectF &,
const QBrush &);
391 inline void fillRect(
int x,
int y,
int w,
int h,
const QBrush &);
392 void fillRect(
const QRect &,
const QBrush &);
394 void fillRect(
const QRectF &,
const QColor &color);
395 inline void fillRect(
int x,
int y,
int w,
int h,
const QColor &color);
396 void fillRect(
const QRect &,
const QColor &color);
398 inline void fillRect(
int x,
int y,
int w,
int h, Qt::GlobalColor c);
399 inline void fillRect(
const QRect &r, Qt::GlobalColor c);
400 inline void fillRect(
const QRectF &r, Qt::GlobalColor c);
402 inline void fillRect(
int x,
int y,
int w,
int h, Qt::BrushStyle style);
403 inline void fillRect(
const QRect &r, Qt::BrushStyle style);
404 inline void fillRect(
const QRectF &r, Qt::BrushStyle style);
406 inline void fillRect(
int x,
int y,
int w,
int h, QGradient::Preset preset);
407 inline void fillRect(
const QRect &r, QGradient::Preset preset);
408 inline void fillRect(
const QRectF &r, QGradient::Preset preset);
410 void eraseRect(
const QRectF &);
411 inline void eraseRect(
int x,
int y,
int w,
int h);
412 inline void eraseRect(
const QRect &);
417 inline bool testRenderHint(RenderHint hint)
const {
return bool(renderHints() & hint); }
425 Q_DISABLE_COPY(QPainter)
427 void doSetPen(
const QPen &lvalue, QPen *rvalue);
428 void doSetBrush(
const QBrush &lvalue, QBrush *rvalue);
430 std::unique_ptr<QPainterPrivate> d_ptr;
448Q_DECLARE_TYPEINFO(QPainter::PixmapFragment, Q_RELOCATABLE_TYPE);
450Q_DECLARE_OPERATORS_FOR_FLAGS(QPainter::RenderHints)
455inline void QPainter::drawLine(
const QLineF &l)
460inline void QPainter::drawLine(
const QLine &line)
465inline void QPainter::drawLine(
int x1,
int y1,
int x2,
int y2)
467 QLine l(x1, y1, x2, y2);
471inline void QPainter::drawLine(
const QPoint &p1,
const QPoint &p2)
477inline void QPainter::drawLine(
const QPointF &p1,
const QPointF &p2)
479 drawLine(QLineF(p1, p2));
482inline void QPainter::drawLines(
const QList<QLineF> &lines)
484 drawLines(lines.constData(),
int(lines.size()));
487inline void QPainter::drawLines(
const QList<QLine> &lines)
489 drawLines(lines.constData(),
int(lines.size()));
492inline void QPainter::drawLines(
const QList<QPointF> &pointPairs)
494 drawLines(pointPairs.constData(),
int(pointPairs.size() / 2));
497inline void QPainter::drawLines(
const QList<QPoint> &pointPairs)
499 drawLines(pointPairs.constData(),
int(pointPairs.size() / 2));
502inline void QPainter::drawPolyline(
const QPolygonF &polyline)
504 drawPolyline(polyline.constData(),
int(polyline.size()));
507inline void QPainter::drawPolyline(
const QPolygon &polyline)
509 drawPolyline(polyline.constData(),
int(polyline.size()));
512inline void QPainter::drawPolygon(
const QPolygonF &polygon, Qt::FillRule fillRule)
514 drawPolygon(polygon.constData(),
int(polygon.size()), fillRule);
517inline void QPainter::drawPolygon(
const QPolygon &polygon, Qt::FillRule fillRule)
519 drawPolygon(polygon.constData(),
int(polygon.size()), fillRule);
522inline void QPainter::drawConvexPolygon(
const QPolygonF &poly)
524 drawConvexPolygon(poly.constData(),
int(poly.size()));
527inline void QPainter::drawConvexPolygon(
const QPolygon &poly)
529 drawConvexPolygon(poly.constData(),
int(poly.size()));
532inline void QPainter::drawRect(
const QRectF &rect)
537inline void QPainter::drawRect(
int x,
int y,
int w,
int h)
543inline void QPainter::drawRect(
const QRect &r)
548inline void QPainter::drawRects(
const QList<QRectF> &rects)
550 drawRects(rects.constData(),
int(rects.size()));
553inline void QPainter::drawRects(
const QList<QRect> &rects)
555 drawRects(rects.constData(),
int(rects.size()));
558inline void QPainter::drawPoint(
const QPointF &p)
563inline void QPainter::drawPoint(
int x,
int y)
569inline void QPainter::drawPoint(
const QPoint &p)
574inline void QPainter::drawPoints(
const QPolygonF &points)
576 drawPoints(points.constData(),
int(points.size()));
579inline void QPainter::drawPoints(
const QPolygon &points)
581 drawPoints(points.constData(),
int(points.size()));
584inline void QPainter::drawRoundedRect(
int x,
int y,
int w,
int h, qreal xRadius, qreal yRadius,
587 drawRoundedRect(QRectF(x, y, w, h), xRadius, yRadius, mode);
590inline void QPainter::drawRoundedRect(
const QRect &rect, qreal xRadius, qreal yRadius,
593 drawRoundedRect(QRectF(rect), xRadius, yRadius, mode);
596inline void QPainter::drawEllipse(
int x,
int y,
int w,
int h)
598 drawEllipse(QRect(x, y, w, h));
601inline void QPainter::drawEllipse(
const QPointF ¢er, qreal rx, qreal ry)
603 drawEllipse(QRectF(center.x() - rx, center.y() - ry, 2 * rx, 2 * ry));
606inline void QPainter::drawEllipse(
const QPoint ¢er,
int rx,
int ry)
608 drawEllipse(QRect(center.x() - rx, center.y() - ry, 2 * rx, 2 * ry));
611inline void QPainter::drawArc(
const QRect &r,
int a,
int alen)
613 drawArc(QRectF(r), a, alen);
616inline void QPainter::drawArc(
int x,
int y,
int w,
int h,
int a,
int alen)
618 drawArc(QRectF(x, y, w, h), a, alen);
621inline void QPainter::drawPie(
const QRect &rect,
int a,
int alen)
623 drawPie(QRectF(rect), a, alen);
626inline void QPainter::drawPie(
int x,
int y,
int w,
int h,
int a,
int alen)
628 drawPie(QRectF(x, y, w, h), a, alen);
631inline void QPainter::drawChord(
const QRect &rect,
int a,
int alen)
633 drawChord(QRectF(rect), a, alen);
636inline void QPainter::drawChord(
int x,
int y,
int w,
int h,
int a,
int alen)
638 drawChord(QRectF(x, y, w, h), a, alen);
641inline void QPainter::setClipRect(
int x,
int y,
int w,
int h, Qt::ClipOperation op)
643 setClipRect(QRect(x, y, w, h), op);
646inline void QPainter::eraseRect(
const QRect &rect)
648 eraseRect(QRectF(rect));
651inline void QPainter::eraseRect(
int x,
int y,
int w,
int h)
653 eraseRect(QRectF(x, y, w, h));
656inline void QPainter::fillRect(
int x,
int y,
int w,
int h,
const QBrush &b)
658 fillRect(QRect(x, y, w, h), b);
661inline void QPainter::fillRect(
int x,
int y,
int w,
int h,
const QColor &b)
663 fillRect(QRect(x, y, w, h), b);
666inline void QPainter::fillRect(
int x,
int y,
int w,
int h, Qt::GlobalColor c)
668 fillRect(QRect(x, y, w, h), QColor(c));
671inline void QPainter::fillRect(
const QRect &r, Qt::GlobalColor c)
673 fillRect(r, QColor(c));
676inline void QPainter::fillRect(
const QRectF &r, Qt::GlobalColor c)
678 fillRect(r, QColor(c));
681inline void QPainter::fillRect(
int x,
int y,
int w,
int h, Qt::BrushStyle style)
683 fillRect(QRectF(x, y, w, h), QBrush(style));
686inline void QPainter::fillRect(
const QRect &r, Qt::BrushStyle style)
688 fillRect(QRectF(r), QBrush(style));
691inline void QPainter::fillRect(
const QRectF &r, Qt::BrushStyle style)
693 fillRect(r, QBrush(style));
696inline void QPainter::fillRect(
int x,
int y,
int w,
int h, QGradient::Preset p)
698 fillRect(QRect(x, y, w, h), QGradient(p));
701inline void QPainter::fillRect(
const QRect &r, QGradient::Preset p)
703 fillRect(r, QGradient(p));
706inline void QPainter::fillRect(
const QRectF &r, QGradient::Preset p)
708 fillRect(r, QGradient(p));
711#if QT_GUI_INLINE_IMPL_SINCE(6
, 11
)
713void QPainter::setPen(
const QPen &p)
715 doSetPen(p,
nullptr);
718void QPainter::setBrush(
const QBrush &b)
720 doSetBrush(b,
nullptr);
726inline void QPainter::setBrushOrigin(
int x,
int y)
728 setBrushOrigin(QPoint(x, y));
731inline void QPainter::setBrushOrigin(
const QPoint &p)
733 setBrushOrigin(QPointF(p));
736inline void QPainter::drawTiledPixmap(
const QRect &rect,
const QPixmap &pm,
const QPoint &offset)
738 drawTiledPixmap(QRectF(rect), pm, QPointF(offset));
741inline void QPainter::drawTiledPixmap(
int x,
int y,
int w,
int h,
const QPixmap &pm,
int sx,
int sy)
743 drawTiledPixmap(QRectF(x, y, w, h), pm, QPointF(sx, sy));
746inline void QPainter::drawPixmap(
const QRect &targetRect,
const QPixmap &pixmap,
const QRect &sourceRect)
748 drawPixmap(QRectF(targetRect), pixmap, QRectF(sourceRect));
751inline void QPainter::drawPixmap(
const QPoint &p,
const QPixmap &pm)
753 drawPixmap(QPointF(p), pm);
756inline void QPainter::drawPixmap(
const QRect &r,
const QPixmap &pm)
758 drawPixmap(QRectF(r), pm, QRectF());
761inline void QPainter::drawPixmap(
int x,
int y,
const QPixmap &pm)
763 drawPixmap(QPointF(x, y), pm);
766inline void QPainter::drawPixmap(
int x,
int y,
int w,
int h,
const QPixmap &pm)
768 drawPixmap(QRectF(x, y, w, h), pm, QRectF());
771inline void QPainter::drawPixmap(
int x,
int y,
int w,
int h,
const QPixmap &pm,
772 int sx,
int sy,
int sw,
int sh)
774 drawPixmap(QRectF(x, y, w, h), pm, QRectF(sx, sy, sw, sh));
777inline void QPainter::drawPixmap(
int x,
int y,
const QPixmap &pm,
778 int sx,
int sy,
int sw,
int sh)
780 drawPixmap(QRectF(x, y, -1, -1), pm, QRectF(sx, sy, sw, sh));
783inline void QPainter::drawPixmap(
const QPointF &p,
const QPixmap &pm,
const QRectF &sr)
785 drawPixmap(QRectF(p.x(), p.y(), -1, -1), pm, sr);
788inline void QPainter::drawPixmap(
const QPoint &p,
const QPixmap &pm,
const QRect &sr)
790 drawPixmap(QRectF(p.x(), p.y(), -1, -1), pm, sr);
793inline void QPainter::drawTextItem(
int x,
int y,
const QTextItem &ti)
795 drawTextItem(QPointF(x, y), ti);
798inline void QPainter::drawImage(
const QRect &targetRect,
const QImage &image,
const QRect &sourceRect,
799 Qt::ImageConversionFlags flags)
801 drawImage(QRectF(targetRect), image, QRectF(sourceRect), flags);
804inline void QPainter::drawImage(
const QPointF &p,
const QImage &image,
const QRectF &sr,
805 Qt::ImageConversionFlags flags)
807 drawImage(QRectF(p.x(), p.y(), -1, -1), image, sr, flags);
810inline void QPainter::drawImage(
const QPoint &p,
const QImage &image,
const QRect &sr,
811 Qt::ImageConversionFlags flags)
813 drawImage(QRect(p.x(), p.y(), -1, -1), image, sr, flags);
817inline void QPainter::drawImage(
const QRectF &r,
const QImage &image)
819 drawImage(r, image, QRect(0, 0, image.width(), image.height()));
822inline void QPainter::drawImage(
const QRect &r,
const QImage &image)
824 drawImage(r, image, QRectF(0, 0, image.width(), image.height()));
827inline void QPainter::drawImage(
const QPoint &p,
const QImage &image)
829 drawImage(QPointF(p), image);
832inline void QPainter::drawImage(
int x,
int y,
const QImage &image,
int sx,
int sy,
int sw,
int sh,
833 Qt::ImageConversionFlags flags)
835 if (sx == 0 && sy == 0 && sw == -1 && sh == -1 && flags == Qt::AutoColor)
836 drawImage(QPointF(x, y), image);
838 drawImage(QRectF(x, y, -1, -1), image, QRectF(sx, sy, sw, sh), flags);
841inline void QPainter::drawStaticText(
const QPoint &p,
const QStaticText &staticText)
843 drawStaticText(QPointF(p), staticText);
846inline void QPainter::drawStaticText(
int x,
int y,
const QStaticText &staticText)
848 drawStaticText(QPointF(x, y), staticText);
851inline void QPainter::drawTextItem(
const QPoint &p,
const QTextItem &ti)
853 drawTextItem(QPointF(p), ti);
856inline void QPainter::drawText(
const QPoint &p,
const QString &s)
858 drawText(QPointF(p), s);
861inline void QPainter::drawText(
int x,
int y,
int w,
int h,
int flags,
const QString &str, QRect *br)
863 drawText(QRect(x, y, w, h), flags, str, br);
866inline void QPainter::drawText(
int x,
int y,
const QString &s)
868 drawText(QPointF(x, y), s);
871inline QRect QPainter::boundingRect(
int x,
int y,
int w,
int h,
int flags,
const QString &text)
873 return boundingRect(QRect(x, y, w, h), flags, text);
876inline void QPainter::translate(qreal dx, qreal dy)
878 translate(QPointF(dx, dy));
881inline void QPainter::translate(
const QPoint &offset)
883 translate(offset.x(), offset.y());
886inline void QPainter::setViewport(
int x,
int y,
int w,
int h)
888 setViewport(QRect(x, y, w, h));
891inline void QPainter::setWindow(
int x,
int y,
int w,
int h)
893 setWindow(QRect(x, y, w, h));
897inline void QPainter::drawPicture(
int x,
int y,
const QPicture &p)
899 drawPicture(QPoint(x, y), p);
902inline void QPainter::drawPicture(
const QPoint &pt,
const QPicture &p)
904 drawPicture(QPointF(pt), p);
\inmodule QtCore\reentrant
QIODevice * device() const
Returns the device currently assigned to QImageReader, or \nullptr if no device has been assigned.
virtual void drawLines(const QLineF *lines, int lineCount)
The default implementation splits the list of lines in lines into lineCount separate calls to drawPat...
virtual void drawPoints(const QPointF *points, int pointCount)
Draws the first pointCount points in the buffer points.
virtual void drawRects(const QRectF *rects, int rectCount)
Draws the first rectCount rectangles in the buffer rects.
virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags=Qt::AutoColor)
Reimplement this function to draw the part of the image specified by the sr rectangle in the given re...
virtual void drawEllipse(const QRectF &r)
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect.
The QPainter class performs low-level painting on widgets and other paint devices.
const QBrush & background() const
Returns the current background brush.
void eraseRect(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
CompositionMode compositionMode() const
Returns the current composition mode.
void drawPolyline(const QPolygonF &polyline)
This is an overloaded member function, provided for convenience. It differs from the above function o...
const QPen & pen() const
Returns the painter's current pen.
void setBackground(const QBrush &bg)
Sets the background brush of the painter to the given brush.
void drawLines(const QList< QLineF > &lines)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setClipping(bool enable)
Enables clipping if enable is true, or disables clipping if enable is false.
Qt::LayoutDirection layoutDirection() const
Returns the layout direction used by the painter when drawing text.
RenderHints renderHints() const
Returns a flag that specifies the rendering hints that are set for this painter.
void drawPath(const QPainterPath &path)
Draws the given painter path using the current pen for outline and the current brush for filling.
QPainter(QPaintDevice *)
Constructs a painter that begins painting the paint device immediately.
void setWorldMatrixEnabled(bool enabled)
void fillRect(int x, int y, int w, int h, const QColor &color)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawPolygon(const QPolygon &polygon, Qt::FillRule fillRule=Qt::OddEvenFill)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void strokePath(const QPainterPath &path, const QPen &pen)
Draws the outline (strokes) the path path with the pen specified by pen.
void setPen(const QColor &color)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawText(int x, int y, const QString &s)
This is an overloaded member function, provided for convenience. It differs from the above function o...
PixmapFragmentHint
\variable QPainter::PixmapFragment::x
void setViewport(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawChord(int x, int y, int w, int h, int a, int alen)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QPaintEngine * paintEngine() const
Returns the paint engine that the painter is currently operating on if the painter is active; otherwi...
QTransform combinedTransform() const
Returns the transformation matrix combining the current window/viewport and world transformation.
QRect boundingRect(int x, int y, int w, int h, int flags, const QString &text)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool begin(QPaintDevice *)
Begins painting the paint device and returns true if successful; otherwise returns false.
void translate(qreal dx, qreal dy)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setBrushOrigin(int x, int y)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawConvexPolygon(const QPolygon &polygon)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setClipPath(const QPainterPath &path, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip path for the painter to the given path, with the clip operation.
void setBackgroundMode(Qt::BGMode mode)
Sets the background mode of the painter to the given mode.
const QFont & font() const
Returns the currently set font used for drawing text.
bool worldMatrixEnabled() const
void setLayoutDirection(Qt::LayoutDirection direction)
Sets the layout direction used by the painter when drawing text, to the specified direction.
void restore()
Restores the current painter state (pops a saved state off the stack).
void rotate(qreal a)
Rotates the coordinate system clockwise.
void scale(qreal sx, qreal sy)
Scales the coordinate system by ({sx}, {sy}).
const QTransform & worldTransform() const
Returns the world transformation matrix.
void drawPicture(int x, int y, const QPicture &picture)
This is an overloaded member function, provided for convenience. It differs from the above function o...
const QBrush & brush() const
Returns the painter's current brush.
void setOpacity(qreal opacity)
void drawPoints(const QPolygonF &points)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QFontMetrics fontMetrics() const
Returns the font metrics for the painter if the painter is active.
friend class QFontEngineFT
void drawArc(int x, int y, int w, int h, int a, int alen)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setPen(const QPen &pen)
Sets the painter's pen to be the given pen.
friend class QOpenGLPaintEngine
void beginNativePainting()
friend class QFontEngineMac
void setClipRect(int x, int y, int w, int h, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the rectangle beginning at (x, y) with the given width ...
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
void drawImage(int x, int y, const QImage &image, int sx=0, int sy=0, int sw=-1, int sh=-1, Qt::ImageConversionFlags flags=Qt::AutoColor)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawRects(const QList< QRectF > &rectangles)
This is an overloaded member function, provided for convenience. It differs from the above function o...
friend class QWin32PaintEngine
friend class QRasterPaintEngine
void drawPoint(int x, int y)
This is an overloaded member function, provided for convenience. It differs from the above function o...
friend class QWin32PaintEnginePrivate
void save()
Saves the current painter state (pushes the state onto a stack).
void setWorldTransform(const QTransform &matrix, bool combine=false)
Sets the world transformation matrix.
void setBrush(Qt::BrushStyle style)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void shear(qreal sh, qreal sv)
Shears the coordinate system by ({sh}, {sv}).
void setFont(const QFont &f)
Sets the painter's font to the given font.
friend class QAlphaPaintEngine
QRegion clipRegion() const
Returns the currently set clip region.
void setWindow(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Qt::BGMode backgroundMode() const
Returns the current background mode.
QPainterPath clipPath() const
Returns the current clip path in logical coordinates.
void drawPoints(const QPolygon &points)
This is an overloaded member function, provided for convenience. It differs from the above function o...
friend class QFontEngineWin
void drawRect(int x1, int y1, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QRect viewport() const
Returns the viewport rectangle.
const QTransform & deviceTransform() const
Returns the matrix that transforms from logical coordinates to device coordinates of the platform dep...
void drawEllipse(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void fillRect(int x, int y, int w, int h, const QBrush &)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void fillPath(const QPainterPath &path, const QBrush &brush)
Fills the given path using the given brush.
void setBrush(QBrush &&brush)
QPoint brushOrigin() const
Returns the current brush origin.
void drawStaticText(int left, int top, const QStaticText &staticText)
void setBrush(const QBrush &brush)
Sets the painter's brush to the given brush.
void drawLine(int x1, int y1, int x2, int y2)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawRoundedRect(int x, int y, int w, int h, qreal xRadius, qreal yRadius, Qt::SizeMode mode=Qt::AbsoluteSize)
bool viewTransformEnabled() const
Returns true if view transformation is enabled; otherwise returns false.
void drawTextItem(int x, int y, const QTextItem &ti)
const QTransform & transform() const
Alias for worldTransform().
void resetTransform()
Resets any transformations that were made using translate(), scale(), shear(), rotate(),...
void drawPolygon(const QPolygonF &polygon, Qt::FillRule fillRule=Qt::OddEvenFill)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QRect window() const
Returns the window rectangle.
void drawPie(int x, int y, int w, int h, int a, int alen)
CompositionMode
Defines the modes supported for digital image compositing.
@ RasterOp_SourceAndNotDestination
@ CompositionMode_Destination
@ RasterOp_NotSourceAndNotDestination
@ CompositionMode_Lighten
@ CompositionMode_ColorDodge
@ CompositionMode_DestinationAtop
@ CompositionMode_SourceOver
@ RasterOp_SourceOrNotDestination
@ RasterOp_NotSourceOrNotDestination
@ RasterOp_SourceXorDestination
@ CompositionMode_DestinationOut
@ CompositionMode_SourceAtop
@ RasterOp_NotSourceAndDestination
@ CompositionMode_Overlay
@ RasterOp_SourceOrDestination
@ RasterOp_ClearDestination
@ RasterOp_NotSourceOrDestination
@ CompositionMode_Multiply
@ CompositionMode_DestinationOver
@ CompositionMode_HardLight
@ CompositionMode_Exclusion
@ CompositionMode_ColorBurn
@ RasterOp_NotSourceXorDestination
@ CompositionMode_Difference
@ RasterOp_NotDestination
@ CompositionMode_SoftLight
@ CompositionMode_DestinationIn
@ CompositionMode_SourceOut
@ RasterOp_SourceAndDestination
@ CompositionMode_SourceIn
@ RasterOp_SetDestination
QRectF clipBoundingRect() const
Returns the bounding rectangle of the current clip if there is a clip; otherwise returns an empty rec...
void setViewTransformEnabled(bool enable)
Enables view transformations if enable is true, or disables view transformations if enable is false.
void drawPolyline(const QPolygon &polygon)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isActive() const
Returns true if begin() has been called and end() has not yet been called; otherwise returns false.
QPointF brushOriginF() const
Returns the current brush origin.
friend class QPaintEngineExPrivate
friend class QPaintEngine
void setRenderHints(RenderHints hints, bool on=true)
void fillRect(int x, int y, int w, int h, Qt::GlobalColor c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool hasClipping() const
Returns true if clipping has been set; otherwise returns false.
QFontInfo fontInfo() const
Returns the font info for the painter if the painter is active.
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint.
void setPen(Qt::PenStyle style)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
void setTransform(const QTransform &transform, bool combine=false)
bool testRenderHint(RenderHint hint) const
void drawConvexPolygon(const QPolygonF &polygon)
This is an overloaded member function, provided for convenience. It differs from the above function o...
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
The QPolygon class provides a list of points using integer precision.
The QScreen class is used to query screen properties. \inmodule QtGui.
Combined button and popup list for selecting options.
static QBitmap makeBitmap(QImage &&image, Qt::ImageConversionFlags flags)
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
void(* QImageCleanupFunction)(void *)