7#include <QtGui/qtguiglobal.h>
8#include <QtCore/qnamespace.h>
9#include <QtCore/qrect.h>
10#include <QtCore/qpoint.h>
11#include <QtCore/qscopedpointer.h>
12#include <QtGui/qpixmap.h>
13#include <QtGui/qimage.h>
14#include <QtGui/qtextoption.h>
17#ifndef QT_INCLUDE_COMPAT
18#include <QtGui/qpolygon.h>
19#include <QtGui/qpen.h>
20#include <QtGui/qbrush.h>
21#include <QtGui/qtransform.h>
22#include <QtGui/qfontinfo.h>
23#include <QtGui/qfontmetrics.h>
43class QPainterPrivateDeleter;
47 Q_DECLARE_PRIVATE(QPainter)
53 TextAntialiasing = 0x02,
54 SmoothPixmapTransform = 0x04,
55 VerticalSubpixelPositioning = 0x08,
56 LosslessImageRendering = 0x40,
57 NonCosmeticBrushPatterns = 0x80
61 Q_DECLARE_FLAGS(RenderHints, RenderHint)
64 class PixmapFragment {
76 static PixmapFragment Q_GUI_EXPORT create(
const QPointF &pos,
const QRectF &sourceRect,
77 qreal scaleX = 1, qreal scaleY = 1,
78 qreal rotation = 0, qreal opacity = 1);
85 Q_DECLARE_FLAGS(PixmapFragmentHints, PixmapFragmentHint)
91 QPaintDevice *
device()
const;
93 bool begin(QPaintDevice *);
152 void setPen(
const QColor &color);
153 QT_GUI_INLINE_SINCE(6, 11)
155 void setPen(QPen &&pen) { doSetPen(pen, &pen); }
156 void setPen(Qt::PenStyle style);
157 const QPen &
pen()
const;
159 QT_GUI_INLINE_SINCE(6, 11)
161 void setBrush(QBrush &&brush) { doSetBrush(brush, &brush); }
162 void setBrush(Qt::BrushStyle style);
164 void setBrush(Qt::GlobalColor color) { setBrush(QColor(color)); }
165 const QBrush &
brush()
const;
174 inline void setBrushOrigin(
const QPoint &);
175 void setBrushOrigin(
const QPointF &);
187 void setClipRect(
const QRectF &, Qt::ClipOperation op = Qt::ReplaceClip);
188 void setClipRect(
const QRect &, Qt::ClipOperation op = Qt::ReplaceClip);
204 void setTransform(
const QTransform &transform,
bool combine =
false);
217 void scale(qreal sx, qreal sy);
218 void shear(qreal sh, qreal sv);
221 void translate(
const QPointF &offset);
222 inline void translate(
const QPoint &offset);
223 inline void translate(qreal dx, qreal dy);
226 void setWindow(
const QRect &window);
227 inline void setWindow(
int x,
int y,
int w,
int h);
230 void setViewport(
const QRect &viewport);
231 inline void setViewport(
int x,
int y,
int w,
int h);
237 void strokePath(
const QPainterPath &path,
const QPen &pen);
238 void fillPath(
const QPainterPath &path,
const QBrush &brush);
239 void drawPath(
const QPainterPath &path);
241 inline void drawPoint(
const QPointF &pt);
242 inline void drawPoint(
const QPoint &p);
246 inline void drawPoints(
const QPolygonF &points);
247 void drawPoints(
const QPoint *points,
int pointCount);
250 inline void drawLine(
const QLineF &line);
251 inline void drawLine(
const QLine &line);
252 inline void drawLine(
int x1,
int y1,
int x2,
int y2);
253 inline void drawLine(
const QPoint &p1,
const QPoint &p2);
256 void drawLines(
const QLineF *lines,
int lineCount);
257 inline void drawLines(
const QList<QLineF> &lines);
258 void drawLines(
const QPointF *pointPairs,
int lineCount);
259 inline void drawLines(
const QList<QPointF> &pointPairs);
260 void drawLines(
const QLine *lines,
int lineCount);
261 inline void drawLines(
const QList<QLine> &lines);
262 void drawLines(
const QPoint *pointPairs,
int lineCount);
263 inline void drawLines(
const QList<QPoint> &pointPairs);
265 inline void drawRect(
const QRectF &rect);
266 inline void drawRect(
int x1,
int y1,
int w,
int h);
267 inline void drawRect(
const QRect &rect);
269 void drawRects(
const QRectF *rects,
int rectCount);
270 inline void drawRects(
const QList<QRectF> &rectangles);
271 void drawRects(
const QRect *rects,
int rectCount);
272 inline void drawRects(
const QList<QRect> &rectangles);
275 void drawEllipse(
const QRect &r);
276 inline void drawEllipse(
int x,
int y,
int w,
int h);
278 inline void drawEllipse(
const QPointF ¢er, qreal rx, qreal ry);
279 inline void drawEllipse(
const QPoint ¢er,
int rx,
int ry);
281 void drawPolyline(
const QPointF *points,
int pointCount);
283 void drawPolyline(
const QPoint *points,
int pointCount);
286 void drawPolygon(
const QPointF *points,
int pointCount, Qt::FillRule fillRule = Qt::OddEvenFill);
288 void drawPolygon(
const QPoint *points,
int pointCount, Qt::FillRule fillRule = Qt::OddEvenFill);
291 void drawConvexPolygon(
const QPointF *points,
int pointCount);
293 void drawConvexPolygon(
const QPoint *points,
int pointCount);
296 void drawArc(
const QRectF &rect,
int a,
int alen);
297 inline void drawArc(
const QRect &,
int a,
int alen);
298 inline void drawArc(
int x,
int y,
int w,
int h,
int a,
int alen);
300 void drawPie(
const QRectF &rect,
int a,
int alen);
301 inline void drawPie(
int x,
int y,
int w,
int h,
int a,
int alen);
302 inline void drawPie(
const QRect &,
int a,
int alen);
304 void drawChord(
const QRectF &rect,
int a,
int alen);
305 inline void drawChord(
int x,
int y,
int w,
int h,
int a,
int alen);
306 inline void drawChord(
const QRect &,
int a,
int alen);
308 void drawRoundedRect(
const QRectF &rect, qreal xRadius, qreal yRadius,
309 Qt::SizeMode mode = Qt::AbsoluteSize);
310 inline void drawRoundedRect(
int x,
int y,
int w,
int h, qreal xRadius, qreal yRadius,
312 inline void drawRoundedRect(
const QRect &rect, qreal xRadius, qreal yRadius,
313 Qt::SizeMode mode = Qt::AbsoluteSize);
315 void drawTiledPixmap(
const QRectF &rect,
const QPixmap &pm,
const QPointF &offset = QPointF());
316 inline void drawTiledPixmap(
int x,
int y,
int w,
int h,
const QPixmap &,
int sx=0,
int sy=0);
317 inline void drawTiledPixmap(
const QRect &,
const QPixmap &,
const QPoint & = QPoint());
319 void drawPicture(
const QPointF &p,
const QPicture &picture);
320 inline void drawPicture(
int x,
int y,
const QPicture &picture);
321 inline void drawPicture(
const QPoint &p,
const QPicture &picture);
324 void drawPixmap(
const QRectF &targetRect,
const QPixmap &pixmap,
const QRectF &sourceRect);
325 inline void drawPixmap(
const QRect &targetRect,
const QPixmap &pixmap,
const QRect &sourceRect);
326 inline void drawPixmap(
int x,
int y,
int w,
int h,
const QPixmap &pm,
327 int sx,
int sy,
int sw,
int sh);
328 inline void drawPixmap(
int x,
int y,
const QPixmap &pm,
329 int sx,
int sy,
int sw,
int sh);
330 inline void drawPixmap(
const QPointF &p,
const QPixmap &pm,
const QRectF &sr);
331 inline void drawPixmap(
const QPoint &p,
const QPixmap &pm,
const QRect &sr);
332 void drawPixmap(
const QPointF &p,
const QPixmap &pm);
333 inline void drawPixmap(
const QPoint &p,
const QPixmap &pm);
334 inline void drawPixmap(
int x,
int y,
const QPixmap &pm);
335 inline void drawPixmap(
const QRect &r,
const QPixmap &pm);
336 inline void drawPixmap(
int x,
int y,
int w,
int h,
const QPixmap &pm);
338 void drawPixmapFragments(
const PixmapFragment *fragments,
int fragmentCount,
339 const QPixmap &pixmap, PixmapFragmentHints hints = PixmapFragmentHints());
341 void drawImage(
const QRectF &targetRect,
const QImage &image,
const QRectF &sourceRect,
343 inline void drawImage(
const QRect &targetRect,
const QImage &image,
const QRect &sourceRect,
344 Qt::ImageConversionFlags flags = Qt::AutoColor);
345 inline void drawImage(
const QPointF &p,
const QImage &image,
const QRectF &sr,
346 Qt::ImageConversionFlags flags = Qt::AutoColor);
347 inline void drawImage(
const QPoint &p,
const QImage &image,
const QRect &sr,
348 Qt::ImageConversionFlags flags = Qt::AutoColor);
349 inline void drawImage(
const QRectF &r,
const QImage &image);
350 inline void drawImage(
const QRect &r,
const QImage &image);
351 void drawImage(
const QPointF &p,
const QImage &image);
352 inline void drawImage(
const QPoint &p,
const QImage &image);
353 inline void drawImage(
int x,
int y,
const QImage &image,
int sx = 0,
int sy = 0,
354 int sw = -1,
int sh = -1, Qt::ImageConversionFlags flags =
Qt::
AutoColor);
359#if !defined(QT_NO_RAWFONT)
360 void drawGlyphRun(
const QPointF &position,
const QGlyphRun &glyphRun);
363 void drawStaticText(
const QPointF &topLeftPosition,
const QStaticText &staticText);
364 inline void drawStaticText(
const QPoint &topLeftPosition,
const QStaticText &staticText);
365 inline void drawStaticText(
int left,
int top,
const QStaticText &staticText);
367 void drawText(
const QPointF &p,
const QString &s);
368 inline void drawText(
const QPoint &p,
const QString &s);
369 inline void drawText(
int x,
int y,
const QString &s);
371 void drawText(
const QPointF &p,
const QString &str,
int tf,
int justificationPadding);
373 void drawText(
const QRectF &r,
int flags,
const QString &text, QRectF *br =
nullptr);
374 void drawText(
const QRect &r,
int flags,
const QString &text, QRect *br =
nullptr);
375 inline void drawText(
int x,
int y,
int w,
int h,
int flags,
const QString &text, QRect *br =
nullptr);
377 void drawText(
const QRectF &r,
const QString &text,
const QTextOption &o = QTextOption());
379 QRectF boundingRect(
const QRectF &rect,
int flags,
const QString &text);
380 QRect boundingRect(
const QRect &rect,
int flags,
const QString &text);
381 inline QRect
boundingRect(
int x,
int y,
int w,
int h,
int flags,
const QString &text);
383 QRectF boundingRect(
const QRectF &rect,
const QString &text,
const QTextOption &o = QTextOption());
385 void drawTextItem(
const QPointF &p,
const QTextItem &ti);
386 inline void drawTextItem(
int x,
int y,
const QTextItem &ti);
387 inline void drawTextItem(
const QPoint &p,
const QTextItem &ti);
389 void fillRect(
const QRectF &,
const QBrush &);
390 inline void fillRect(
int x,
int y,
int w,
int h,
const QBrush &);
391 void fillRect(
const QRect &,
const QBrush &);
393 void fillRect(
const QRectF &,
const QColor &color);
394 inline void fillRect(
int x,
int y,
int w,
int h,
const QColor &color);
395 void fillRect(
const QRect &,
const QColor &color);
397 inline void fillRect(
int x,
int y,
int w,
int h, Qt::GlobalColor c);
398 inline void fillRect(
const QRect &r, Qt::GlobalColor c);
399 inline void fillRect(
const QRectF &r, Qt::GlobalColor c);
401 inline void fillRect(
int x,
int y,
int w,
int h, Qt::BrushStyle style);
402 inline void fillRect(
const QRect &r, Qt::BrushStyle style);
403 inline void fillRect(
const QRectF &r, Qt::BrushStyle style);
405 inline void fillRect(
int x,
int y,
int w,
int h, QGradient::Preset preset);
406 inline void fillRect(
const QRect &r, QGradient::Preset preset);
407 inline void fillRect(
const QRectF &r, QGradient::Preset preset);
409 void eraseRect(
const QRectF &);
410 inline void eraseRect(
int x,
int y,
int w,
int h);
411 inline void eraseRect(
const QRect &);
416 inline bool testRenderHint(RenderHint hint)
const {
return bool(renderHints() & hint); }
424 Q_DISABLE_COPY(QPainter)
426 void doSetPen(
const QPen &lvalue, QPen *rvalue);
427 void doSetBrush(
const QBrush &lvalue, QBrush *rvalue);
429 std::unique_ptr<QPainterPrivate> d_ptr;
447Q_DECLARE_TYPEINFO(QPainter::PixmapFragment, Q_RELOCATABLE_TYPE);
449Q_DECLARE_OPERATORS_FOR_FLAGS(QPainter::RenderHints)
454inline void QPainter::drawLine(
const QLineF &l)
459inline void QPainter::drawLine(
const QLine &line)
464inline void QPainter::drawLine(
int x1,
int y1,
int x2,
int y2)
466 QLine l(x1, y1, x2, y2);
470inline void QPainter::drawLine(
const QPoint &p1,
const QPoint &p2)
476inline void QPainter::drawLine(
const QPointF &p1,
const QPointF &p2)
478 drawLine(QLineF(p1, p2));
481inline void QPainter::drawLines(
const QList<QLineF> &lines)
483 drawLines(lines.constData(),
int(lines.size()));
486inline void QPainter::drawLines(
const QList<QLine> &lines)
488 drawLines(lines.constData(),
int(lines.size()));
491inline void QPainter::drawLines(
const QList<QPointF> &pointPairs)
493 drawLines(pointPairs.constData(),
int(pointPairs.size() / 2));
496inline void QPainter::drawLines(
const QList<QPoint> &pointPairs)
498 drawLines(pointPairs.constData(),
int(pointPairs.size() / 2));
501inline void QPainter::drawPolyline(
const QPolygonF &polyline)
503 drawPolyline(polyline.constData(),
int(polyline.size()));
506inline void QPainter::drawPolyline(
const QPolygon &polyline)
508 drawPolyline(polyline.constData(),
int(polyline.size()));
511inline void QPainter::drawPolygon(
const QPolygonF &polygon, Qt::FillRule fillRule)
513 drawPolygon(polygon.constData(),
int(polygon.size()), fillRule);
516inline void QPainter::drawPolygon(
const QPolygon &polygon, Qt::FillRule fillRule)
518 drawPolygon(polygon.constData(),
int(polygon.size()), fillRule);
521inline void QPainter::drawConvexPolygon(
const QPolygonF &poly)
523 drawConvexPolygon(poly.constData(),
int(poly.size()));
526inline void QPainter::drawConvexPolygon(
const QPolygon &poly)
528 drawConvexPolygon(poly.constData(),
int(poly.size()));
531inline void QPainter::drawRect(
const QRectF &rect)
536inline void QPainter::drawRect(
int x,
int y,
int w,
int h)
542inline void QPainter::drawRect(
const QRect &r)
547inline void QPainter::drawRects(
const QList<QRectF> &rects)
549 drawRects(rects.constData(),
int(rects.size()));
552inline void QPainter::drawRects(
const QList<QRect> &rects)
554 drawRects(rects.constData(),
int(rects.size()));
557inline void QPainter::drawPoint(
const QPointF &p)
562inline void QPainter::drawPoint(
int x,
int y)
568inline void QPainter::drawPoint(
const QPoint &p)
573inline void QPainter::drawPoints(
const QPolygonF &points)
575 drawPoints(points.constData(),
int(points.size()));
578inline void QPainter::drawPoints(
const QPolygon &points)
580 drawPoints(points.constData(),
int(points.size()));
583inline void QPainter::drawRoundedRect(
int x,
int y,
int w,
int h, qreal xRadius, qreal yRadius,
586 drawRoundedRect(QRectF(x, y, w, h), xRadius, yRadius, mode);
589inline void QPainter::drawRoundedRect(
const QRect &rect, qreal xRadius, qreal yRadius,
592 drawRoundedRect(QRectF(rect), xRadius, yRadius, mode);
595inline void QPainter::drawEllipse(
int x,
int y,
int w,
int h)
597 drawEllipse(QRect(x, y, w, h));
600inline void QPainter::drawEllipse(
const QPointF ¢er, qreal rx, qreal ry)
602 drawEllipse(QRectF(center.x() - rx, center.y() - ry, 2 * rx, 2 * ry));
605inline void QPainter::drawEllipse(
const QPoint ¢er,
int rx,
int ry)
607 drawEllipse(QRect(center.x() - rx, center.y() - ry, 2 * rx, 2 * ry));
610inline void QPainter::drawArc(
const QRect &r,
int a,
int alen)
612 drawArc(QRectF(r), a, alen);
615inline void QPainter::drawArc(
int x,
int y,
int w,
int h,
int a,
int alen)
617 drawArc(QRectF(x, y, w, h), a, alen);
620inline void QPainter::drawPie(
const QRect &rect,
int a,
int alen)
622 drawPie(QRectF(rect), a, alen);
625inline void QPainter::drawPie(
int x,
int y,
int w,
int h,
int a,
int alen)
627 drawPie(QRectF(x, y, w, h), a, alen);
630inline void QPainter::drawChord(
const QRect &rect,
int a,
int alen)
632 drawChord(QRectF(rect), a, alen);
635inline void QPainter::drawChord(
int x,
int y,
int w,
int h,
int a,
int alen)
637 drawChord(QRectF(x, y, w, h), a, alen);
640inline void QPainter::setClipRect(
int x,
int y,
int w,
int h, Qt::ClipOperation op)
642 setClipRect(QRect(x, y, w, h), op);
645inline void QPainter::eraseRect(
const QRect &rect)
647 eraseRect(QRectF(rect));
650inline void QPainter::eraseRect(
int x,
int y,
int w,
int h)
652 eraseRect(QRectF(x, y, w, h));
655inline void QPainter::fillRect(
int x,
int y,
int w,
int h,
const QBrush &b)
657 fillRect(QRect(x, y, w, h), b);
660inline void QPainter::fillRect(
int x,
int y,
int w,
int h,
const QColor &b)
662 fillRect(QRect(x, y, w, h), b);
665inline void QPainter::fillRect(
int x,
int y,
int w,
int h, Qt::GlobalColor c)
667 fillRect(QRect(x, y, w, h), QColor(c));
670inline void QPainter::fillRect(
const QRect &r, Qt::GlobalColor c)
672 fillRect(r, QColor(c));
675inline void QPainter::fillRect(
const QRectF &r, Qt::GlobalColor c)
677 fillRect(r, QColor(c));
680inline void QPainter::fillRect(
int x,
int y,
int w,
int h, Qt::BrushStyle style)
682 fillRect(QRectF(x, y, w, h), QBrush(style));
685inline void QPainter::fillRect(
const QRect &r, Qt::BrushStyle style)
687 fillRect(QRectF(r), QBrush(style));
690inline void QPainter::fillRect(
const QRectF &r, Qt::BrushStyle style)
692 fillRect(r, QBrush(style));
695inline void QPainter::fillRect(
int x,
int y,
int w,
int h, QGradient::Preset p)
697 fillRect(QRect(x, y, w, h), QGradient(p));
700inline void QPainter::fillRect(
const QRect &r, QGradient::Preset p)
702 fillRect(r, QGradient(p));
705inline void QPainter::fillRect(
const QRectF &r, QGradient::Preset p)
707 fillRect(r, QGradient(p));
710#if QT_GUI_INLINE_IMPL_SINCE(6
, 11
)
712void QPainter::setPen(
const QPen &p)
714 doSetPen(p,
nullptr);
717void QPainter::setBrush(
const QBrush &b)
719 doSetBrush(b,
nullptr);
725inline void QPainter::setBrushOrigin(
int x,
int y)
727 setBrushOrigin(QPoint(x, y));
730inline void QPainter::setBrushOrigin(
const QPoint &p)
732 setBrushOrigin(QPointF(p));
735inline void QPainter::drawTiledPixmap(
const QRect &rect,
const QPixmap &pm,
const QPoint &offset)
737 drawTiledPixmap(QRectF(rect), pm, QPointF(offset));
740inline void QPainter::drawTiledPixmap(
int x,
int y,
int w,
int h,
const QPixmap &pm,
int sx,
int sy)
742 drawTiledPixmap(QRectF(x, y, w, h), pm, QPointF(sx, sy));
745inline void QPainter::drawPixmap(
const QRect &targetRect,
const QPixmap &pixmap,
const QRect &sourceRect)
747 drawPixmap(QRectF(targetRect), pixmap, QRectF(sourceRect));
750inline void QPainter::drawPixmap(
const QPoint &p,
const QPixmap &pm)
752 drawPixmap(QPointF(p), pm);
755inline void QPainter::drawPixmap(
const QRect &r,
const QPixmap &pm)
757 drawPixmap(QRectF(r), pm, QRectF());
760inline void QPainter::drawPixmap(
int x,
int y,
const QPixmap &pm)
762 drawPixmap(QPointF(x, y), pm);
765inline void QPainter::drawPixmap(
int x,
int y,
int w,
int h,
const QPixmap &pm)
767 drawPixmap(QRectF(x, y, w, h), pm, QRectF());
770inline void QPainter::drawPixmap(
int x,
int y,
int w,
int h,
const QPixmap &pm,
771 int sx,
int sy,
int sw,
int sh)
773 drawPixmap(QRectF(x, y, w, h), pm, QRectF(sx, sy, sw, sh));
776inline void QPainter::drawPixmap(
int x,
int y,
const QPixmap &pm,
777 int sx,
int sy,
int sw,
int sh)
779 drawPixmap(QRectF(x, y, -1, -1), pm, QRectF(sx, sy, sw, sh));
782inline void QPainter::drawPixmap(
const QPointF &p,
const QPixmap &pm,
const QRectF &sr)
784 drawPixmap(QRectF(p.x(), p.y(), -1, -1), pm, sr);
787inline void QPainter::drawPixmap(
const QPoint &p,
const QPixmap &pm,
const QRect &sr)
789 drawPixmap(QRectF(p.x(), p.y(), -1, -1), pm, sr);
792inline void QPainter::drawTextItem(
int x,
int y,
const QTextItem &ti)
794 drawTextItem(QPointF(x, y), ti);
797inline void QPainter::drawImage(
const QRect &targetRect,
const QImage &image,
const QRect &sourceRect,
798 Qt::ImageConversionFlags flags)
800 drawImage(QRectF(targetRect), image, QRectF(sourceRect), flags);
803inline void QPainter::drawImage(
const QPointF &p,
const QImage &image,
const QRectF &sr,
804 Qt::ImageConversionFlags flags)
806 drawImage(QRectF(p.x(), p.y(), -1, -1), image, sr, flags);
809inline void QPainter::drawImage(
const QPoint &p,
const QImage &image,
const QRect &sr,
810 Qt::ImageConversionFlags flags)
812 drawImage(QRect(p.x(), p.y(), -1, -1), image, sr, flags);
816inline void QPainter::drawImage(
const QRectF &r,
const QImage &image)
818 drawImage(r, image, QRect(0, 0, image.width(), image.height()));
821inline void QPainter::drawImage(
const QRect &r,
const QImage &image)
823 drawImage(r, image, QRectF(0, 0, image.width(), image.height()));
826inline void QPainter::drawImage(
const QPoint &p,
const QImage &image)
828 drawImage(QPointF(p), image);
831inline void QPainter::drawImage(
int x,
int y,
const QImage &image,
int sx,
int sy,
int sw,
int sh,
832 Qt::ImageConversionFlags flags)
834 if (sx == 0 && sy == 0 && sw == -1 && sh == -1 && flags == Qt::AutoColor)
835 drawImage(QPointF(x, y), image);
837 drawImage(QRectF(x, y, -1, -1), image, QRectF(sx, sy, sw, sh), flags);
840inline void QPainter::drawStaticText(
const QPoint &p,
const QStaticText &staticText)
842 drawStaticText(QPointF(p), staticText);
845inline void QPainter::drawStaticText(
int x,
int y,
const QStaticText &staticText)
847 drawStaticText(QPointF(x, y), staticText);
850inline void QPainter::drawTextItem(
const QPoint &p,
const QTextItem &ti)
852 drawTextItem(QPointF(p), ti);
855inline void QPainter::drawText(
const QPoint &p,
const QString &s)
857 drawText(QPointF(p), s);
860inline void QPainter::drawText(
int x,
int y,
int w,
int h,
int flags,
const QString &str, QRect *br)
862 drawText(QRect(x, y, w, h), flags, str, br);
865inline void QPainter::drawText(
int x,
int y,
const QString &s)
867 drawText(QPointF(x, y), s);
870inline QRect QPainter::boundingRect(
int x,
int y,
int w,
int h,
int flags,
const QString &text)
872 return boundingRect(QRect(x, y, w, h), flags, text);
875inline void QPainter::translate(qreal dx, qreal dy)
877 translate(QPointF(dx, dy));
880inline void QPainter::translate(
const QPoint &offset)
882 translate(offset.x(), offset.y());
885inline void QPainter::setViewport(
int x,
int y,
int w,
int h)
887 setViewport(QRect(x, y, w, h));
890inline void QPainter::setWindow(
int x,
int y,
int w,
int h)
892 setWindow(QRect(x, y, w, h));
896inline void QPainter::drawPicture(
int x,
int y,
const QPicture &p)
898 drawPicture(QPoint(x, y), p);
901inline void QPainter::drawPicture(
const QPoint &pt,
const QPicture &p)
903 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.
static QBitmap makeBitmap(QImage &&image, Qt::ImageConversionFlags flags)
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
void(* QImageCleanupFunction)(void *)