Javascript required
Skip to content Skip to sidebar Skip to footer

Pyqt5 Draw a Half Circle

The QPainter form performs low-level painting on widgets and other paint devices. More than...

Member Function Documentation

QPainter::QPainter(QPaintDevice *device)

Constructs a painter that begins painting the paint device immediately.

This constructor is convenient for short-lived painters, due east.g. in a QWidget::paintEvent() and should be used only once. The constructor calls begin() for you and the QPainter destructor automatically calls stop().

Here's an example using begin() and end():

                        void            MyWidget::paintEvent(QPaintEvent            *) {            QPainter            p;     p.begin(this);     p.drawLine(.            .            .);             p.end(); }

The same example using this constructor:

Since the constructor cannot provide feedback when the initialization of the painter failed you should rather use begin() and terminate() to paint on external devices, due east.g. printers.

See likewise brainstorm() and end().

QPainter::QPainter()

Constructs a painter.

See likewise begin() and end().

QPainter::~QPainter()

Destroys the painter.

const QBrush &QPainter::background() const

Returns the current background castor.

See also setBackground() and Settings.

Qt::BGMode QPainter::backgroundMode() const

Returns the current background mode.

Encounter also setBackgroundMode() and Settings.

bool QPainter::begin(QPaintDevice *device)

Begins painting the paint device and returns truthful if successful; otherwise returns false.

Notice that all painter settings (setPen(), setBrush() etc.) are reset to default values when begin() is called.

The errors that tin occur are serious problems, such every bit these:

            painter-            >begin(0);             QPixmap            paradigm(0            ,            0); painter-            >begin(&image);   painter-            >begin(myWidget); painter2-            >begin(myWidget);          

Note that near of the time, y'all tin can utilise i of the constructors instead of brainstorm(), and that end() is automatically done at destruction.

Warning: A paint device can only be painted by i painter at a time.

See also end() and QPainter().

void QPainter::beginNativePainting()

Flushes the painting pipeline and prepares for the user issuing commands directly to the underlying graphics context. Must exist followed by a call to endNativePainting().

Note that merely the states the underlying paint engine changes will be reset to their respective default states. Usa we reset may alter from release to release. The following states are currently reset in the OpenGL 2 engine:

  • blending is disabled
  • the depth, stencil and scissor tests are disabled
  • the active texture unit is reset to 0
  • the depth mask, depth function and the clear depth are reset to their default values
  • the stencil mask, stencil operation and stencil function are reset to their default values
  • the current color is reset to solid white

If, for example, the OpenGL polygon style is changed by the user inside a beginNativePaint()/endNativePainting() block, information technology will not be reset to the default state by endNativePainting(). Here is an case that shows intermixing of painter commands and raw OpenGL commands:

                        QPainter            painter(this); painter.fillRect(0            ,            0            ,            128            ,            128            ,            Qt            ::greenish); painter.beginNativePainting();  glEnable(GL_SCISSOR_TEST); glScissor(0            ,            0            ,            64            ,            64);  glClearColor(1            ,            0            ,            0            ,            one); glClear(GL_COLOR_BUFFER_BIT);  glDisable(GL_SCISSOR_TEST);  painter.endNativePainting();

This function was introduced in Qt iv.vi.

See too endNativePainting().

QRectF QPainter::boundingRect(const QRectF &rectangle, int flags, const QString &text)

Returns the bounding rectangle of the text equally information technology will appear when drawn inside the given rectangle with the specified flags using the currently set font(); i.e the function tells you where the drawText() function will draw when given the same arguments.

If the text does non fit within the given rectangle using the specified flags, the function returns the required rectangle.

The flags argument is a bitwise OR of the following flags:

  • Qt::AlignLeft
  • Qt::AlignRight
  • Qt::AlignHCenter
  • Qt::AlignTop
  • Qt::AlignBottom
  • Qt::AlignVCenter
  • Qt::AlignCenter
  • Qt::TextSingleLine
  • Qt::TextExpandTabs
  • Qt::TextShowMnemonic
  • Qt::TextWordWrap
  • Qt::TextIncludeTrailingSpaces

If several of the horizontal or several of the vertical alignment flags are set, the resulting alignment is undefined.

Encounter also drawText(), Qt::Alignment, and Qt::TextFlag.

QRect QPainter::boundingRect(const QRect &rectangle, int flags, const QString &text)

This is an overloaded function.

Returns the bounding rectangle of the text as it will appear when drawn within the given rectangle with the specified flags using the currently set font().

QRect QPainter::boundingRect(int x, int y, int w, int h, int flags, const QString &text)

This is an overloaded role.

Returns the bounding rectangle of the given text as it will appear when drawn inside the rectangle offset at the point (x, y) with width w and height h.

QRectF QPainter::boundingRect(const QRectF &rectangle, const QString &text, const QTextOption &option = QTextOption())

This is an overloaded function.

Instead of specifying flags as a bitwise OR of the Qt::AlignmentFlag and Qt::TextFlag, this overloaded part takes an option argument. The QTextOption course provides a description of general rich text backdrop.

See also QTextOption.

const QBrush &QPainter::brush() const

Returns the painter's electric current brush.

Come across likewise QPainter::setBrush() and Settings.

QPoint QPainter::brushOrigin() const

Returns the currently set brush origin.

Come across also setBrushOrigin() and Settings.

QRectF QPainter::clipBoundingRect() const

Returns the bounding rectangle of the electric current prune if in that location is a clip; otherwise returns an empty rectangle. Notation that the clip region is given in logical coordinates.

The bounding rectangle is not guaranteed to exist tight.

This function was introduced in Qt 4.viii.

See also setClipRect(), setClipPath(), and setClipRegion().

QPainterPath QPainter::clipPath() const

Returns the electric current prune path in logical coordinates.

Alarm: QPainter does not store the combined prune explicitly as this is handled past the underlying QPaintEngine, and so the path is recreated on demand and transformed to the electric current logical coordinate system. This is potentially an expensive operation.

Run across also setClipPath(), clipRegion(), and setClipping().

QRegion QPainter::clipRegion() const

Returns the currently set clip region. Note that the prune region is given in logical coordinates.

Warning: QPainter does not store the combined clip explicitly as this is handled past the underlying QPaintEngine, so the path is recreated on demand and transformed to the current logical coordinate system. This is potentially an expensive functioning.

Run into also setClipRegion(), clipPath(), and setClipping().

QTransform QPainter::combinedTransform() const

Returns the transformation matrix combining the electric current window/viewport and world transformation.

See also setWorldTransform(), setWindow(), and setViewport().

QPainter::CompositionMode QPainter::compositionMode() const

Returns the current composition style.

Come across also CompositionMode and setCompositionMode().

QPaintDevice *QPainter::device() const

Returns the paint device on which this painter is currently painting, or nullptr if the painter is not active.

Run across also isActive().

const QTransform &QPainter::deviceTransform() const

Returns the matrix that transforms from logical coordinates to device coordinates of the platform dependent paint device.

This function is only needed when using platform painting commands on the platform dependent handle (Qt::HANDLE), and the platform does not exercise transformations nativly.

The QPaintEngine::PaintEngineFeature enum can exist queried to determine whether the platform performs the transformations or non.

Run into too worldTransform() and QPaintEngine::hasFeature().

void QPainter::drawArc(const QRectF &rectangle, int startAngle, int spanAngle)

Draws the arc defined by the given rectangle, startAngle and spanAngle.

The startAngle and spanAngle must exist specified in 1/16th of a degree, i.e. a full circle equals 5760 (16 * 360). Positive values for the angles mean counter-clockwise while negative values hateful the clockwise management. Zero degrees is at the 3 o'clock position.

                    QRectF                    rectangle(10.0                    ,                    20.0                    ,                    80.0                    ,                    sixty.0);                    int                    startAngle                    =                    30                    *                    xvi;                    int                    spanAngle                    =                    120                    *                    16;                    QPainter                    painter(this); painter.drawArc(rectangle,                    startAngle,                    spanAngle);

See likewise drawPie(), drawChord(), and Coordinate System.

void QPainter::drawArc(const QRect &rectangle, int startAngle, int spanAngle)

This is an overloaded role.

Draws the arc divers past the given rectangle, startAngle and spanAngle.

void QPainter::drawArc(int x, int y, int width, int tiptop, int startAngle, int spanAngle)

This is an overloaded function.

Draws the arc defined by the rectangle showtime at (x, y) with the specified width and acme, and the given startAngle and spanAngle.

void QPainter::drawChord(const QRectF &rectangle, int startAngle, int spanAngle)

Draws the chord defined by the given rectangle, startAngle and spanAngle. The chord is filled with the current brush().

The startAngle and spanAngle must be specified in i/16th of a degree, i.e. a full circle equals 5760 (sixteen * 360). Positive values for the angles mean counter-clockwise while negative values mean the clockwise direction. Zero degrees is at the iii o'clock position.

                    QRectF                    rectangle(x.0                    ,                    twenty.0                    ,                    80.0                    ,                    threescore.0);                    int                    startAngle                    =                    thirty                    *                    xvi;                    int                    spanAngle                    =                    120                    *                    16;                    QPainter                    painter(this); painter.drawChord(rect,                    startAngle,                    spanAngle);

Meet as well drawArc(), drawPie(), and Coordinate Arrangement.

void QPainter::drawChord(int x, int y, int width, int height, int startAngle, int spanAngle)

This is an overloaded function.

Draws the chord defined by the rectangle commencement at (ten, y) with the specified width and pinnacle, and the given startAngle and spanAngle.

void QPainter::drawChord(const QRect &rectangle, int startAngle, int spanAngle)

This is an overloaded office.

Draws the chord defined by the given rectangle, startAngle and spanAngle.

void QPainter::drawConvexPolygon(const QPointF *points, int pointCount)

Draws the convex polygon divers by the first pointCount points in the array points using the current pen.

The commencement point is implicitly continued to the last point, and the polygon is filled with the current brush(). If the supplied polygon is non convex, i.e. it contains at to the lowest degree one angle larger than 180 degrees, the results are undefined.

On some platforms (e.m. X11), the drawConvexPolygon() function tin be faster than the drawPolygon() function.

See besides drawPolygon(), drawPolyline(), and Coordinate Arrangement.

void QPainter::drawConvexPolygon(const QPolygonF &polygon)

This is an overloaded part.

Draws the convex polygon defined by polygon using the current pen and castor.

void QPainter::drawConvexPolygon(const QPoint *points, int pointCount)

This is an overloaded part.

Draws the convex polygon defined by the first pointCount points in the array points using the current pen.

void QPainter::drawConvexPolygon(const QPolygon &polygon)

This is an overloaded function.

Draws the convex polygon defined past polygon using the current pen and brush.

void QPainter::drawEllipse(const QRectF &rectangle)

Draws the ellipse divers by the given rectangle.

A filled ellipse has a size of rectangle.size(). A stroked ellipse has a size of rectangle.size() plus the pen width.

                    QRectF                    rectangle(10.0                    ,                    20.0                    ,                    fourscore.0                    ,                    lx.0);                    QPainter                    painter(this); painter.drawEllipse(rectangle);

See also drawPie() and Coordinate Organization.

void QPainter::drawEllipse(const QRect &rectangle)

This is an overloaded office.

Draws the ellipse divers past the given rectangle.

void QPainter::drawEllipse(int x, int y, int width, int height)

This is an overloaded function.

Draws the ellipse defined by the rectangle beginning at (x, y) with the given width and height.

void QPainter::drawEllipse(const QPointF &center, qreal rx, qreal ry)

This is an overloaded function.

Draws the ellipse positioned at middle with radii rx and ry.

This office was introduced in Qt 4.iv.

void QPainter::drawEllipse(const QPoint &heart, int rx, int ry)

This is an overloaded function.

Draws the ellipse positioned at center with radii rx and ry.

This office was introduced in Qt 4.4.

void QPainter::drawGlyphRun(const QPointF &position, const QGlyphRun &glyphs)

Draws the glyphs represented by glyphs at position. The position gives the border of the baseline for the string of glyphs. The glyphs volition be retrieved from the font selected on glyphs and at offsets given by the positions in glyphs.

This function was introduced in Qt 4.8.

Come across as well QGlyphRun::setRawFont(), QGlyphRun::setPositions(), and QGlyphRun::setGlyphIndexes().

void QPainter::drawImage(const QRectF &target, const QImage &image, const QRectF &source, Qt::ImageConversionFlags flags = Qt::AutoColor)

Draws the rectangular portion source of the given paradigm into the target rectangle in the paint device.

Note: The epitome is scaled to fit the rectangle, if both the epitome and rectangle size disagree.

If the image needs to be modified to fit in a lower-resolution result (e.g. converting from 32-chip to 8-bit), utilize the flags to specify how you would adopt this to happen.

            QRectF            target(10.0            ,            20.0            ,            80.0            ,            sixty.0);            QRectF            source(0.0            ,            0.0            ,            70.0            ,            twoscore.0);            QImage            image(":/images/myImage.png");            QPainter            painter(this); painter.drawImage(target,            paradigm,            source);

See also drawPixmap() and QImage::devicePixelRatio().

void QPainter::drawImage(const QRect &target, const QImage &image, const QRect &source, Qt::ImageConversionFlags flags = Qt::AutoColor)

This is an overloaded function.

Draws the rectangular portion source of the given image into the target rectangle in the pigment device.

Note: The paradigm is scaled to fit the rectangle, if both the image and rectangle size disagree.

void QPainter::drawImage(const QPointF &bespeak, const QImage &image, const QRectF &source, Qt::ImageConversionFlags flags = Qt::AutoColor)

This is an overloaded office.

Draws the rectangular portion source of the given paradigm with its origin at the given point.

void QPainter::drawImage(const QPoint &point, const QImage &image, const QRect &source, Qt::ImageConversionFlags flags = Qt::AutoColor)

This is an overloaded part.

Draws the rectangular portion source of the given image with its origin at the given point.

void QPainter::drawImage(const QRectF &rectangle, const QImage &image)

This is an overloaded part.

Draws the given epitome into the given rectangle.

Note: The image is scaled to fit the rectangle, if both the image and rectangle size disagree.

void QPainter::drawImage(const QRect &rectangle, const QImage &image)

This is an overloaded office.

Draws the given paradigm into the given rectangle.

Note: The epitome is scaled to fit the rectangle, if both the image and rectangle size disagree.

void QPainter::drawImage(const QPointF &point, const QImage &image)

This is an overloaded function.

Draws the given prototype at the given point.

void QPainter::drawImage(const QPoint &point, const QImage &epitome)

This is an overloaded function.

Draws the given image at the given signal.

void QPainter::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 function.

Draws an epitome at (ten, y) by copying a office of image into the paint device.

(x, y) specifies the height-left point in the pigment device that is to be fatigued onto. (sx, sy) specifies the elevation-left point in paradigm that is to be drawn. The default is (0, 0).

(sw, sh) specifies the size of the prototype that is to be fatigued. The default, (0, 0) (and negative) means all the mode to the lesser-correct of the image.

void QPainter::drawLine(const QLineF &line)

Draws a line defined by line.

                    QLineF                    line(10.0                    ,                    fourscore.0                    ,                    90.0                    ,                    20.0);                    QPainter(this); painter.drawLine(line);

See besides drawLines(), drawPolyline(), and Coordinate System.

void QPainter::drawLine(const QLine &line)

This is an overloaded function.

Draws a line defined by line.

void QPainter::drawLine(int x1, int y1, int x2, int y2)

This is an overloaded function.

Draws a line from (x1, y1) to (x2, y2).

void QPainter::drawLine(const QPoint &p1, const QPoint &p2)

This is an overloaded function.

Draws a line from p1 to p2.

void QPainter::drawLine(const QPointF &p1, const QPointF &p2)

This is an overloaded function.

Draws a line from p1 to p2.

void QPainter::drawLines(const QLineF *lines, int lineCount)

Draws the first lineCount lines in the array lines using the current pen.

See also drawLine() and drawPolyline().

void QPainter::drawLines(const QVector<QLineF> &lines)

This is an overloaded function.

Draws the set of lines defined by the list lines using the current pen and brush.

void QPainter::drawLines(const QPointF *pointPairs, int lineCount)

This is an overloaded part.

Draws the beginning lineCount lines in the array pointPairs using the current pen. The lines are specified as pairs of points so the number of entries in pointPairs must be at least lineCount * 2.

void QPainter::drawLines(const QVector<QPointF> &pointPairs)

This is an overloaded function.

Draws a line for each pair of points in the vector pointPairs using the current pen. If in that location is an odd number of points in the array, the concluding point will be ignored.

void QPainter::drawLines(const QLine *lines, int lineCount)

This is an overloaded office.

Draws the offset lineCount lines in the assortment lines using the electric current pen.

void QPainter::drawLines(const QVector<QLine> &lines)

This is an overloaded function.

Draws the ready of lines defined by the list lines using the current pen and brush.

void QPainter::drawLines(const QPoint *pointPairs, int lineCount)

This is an overloaded function.

Draws the beginning lineCount lines in the array pointPairs using the current pen.

void QPainter::drawLines(const QVector<QPoint> &pointPairs)

This is an overloaded function.

Draws a line for each pair of points in the vector pointPairs using the electric current pen.

void QPainter::drawPath(const QPainterPath &path)

Draws the given painter path using the current pen for outline and the electric current brush for filling.

                    QPainterPath                    path; path.moveTo(20                    ,                    80); path.lineTo(twenty                    ,                    30); path.cubicTo(eighty                    ,                    0                    ,                    50                    ,                    50                    ,                    80                    ,                    80);                    QPainter                    painter(this); painter.drawPath(path);

Run into also the Painter Paths example and the Vector Deformation case.

void QPainter::drawPicture(const QPointF &point, const QPicture &picture)

Replays the given picture at the given point.

The QPicture class is a paint device that records and replays QPainter commands. A picture serializes the painter commands to an IO device in a platform-contained format. Everything that can be painted on a widget or pixmap can as well exist stored in a pic.

This function does exactly the same as QPicture::play() when called with point = QPoint(0, 0).

            QPicture            picture;            QPointF            bespeak(10.0            ,            20.0) picture.load("cartoon.pic");            QPainter            painter(this); painter.drawPicture(0            ,            0            ,            motion-picture show);

See also QPicture::play().

void QPainter::drawPicture(int ten, int y, const QPicture &flick)

This is an overloaded function.

Draws the given pic at point (x, y).

void QPainter::drawPicture(const QPoint &point, const QPicture &film)

This is an overloaded function.

Replays the given motion-picture show at the given betoken.

void QPainter::drawPie(const QRectF &rectangle, int startAngle, int spanAngle)

Draws a pie defined by the given rectangle, startAngle and spanAngle.

The pie is filled with the current brush().

The startAngle and spanAngle must be specified in 1/16th of a degree, i.e. a total circumvolve equals 5760 (16 * 360). Positive values for the angles mean counter-clockwise while negative values mean the clockwise direction. Zero degrees is at the 3 o'clock position.

                    QRectF                    rectangle(10.0                    ,                    xx.0                    ,                    80.0                    ,                    60.0);                    int                    startAngle                    =                    30                    *                    xvi;                    int                    spanAngle                    =                    120                    *                    16;                    QPainter                    painter(this); painter.drawPie(rectangle,                    startAngle,                    spanAngle);

See also drawEllipse(), drawChord(), and Coordinate System.

void QPainter::drawPie(int x, int y, int width, int height, int startAngle, int spanAngle)

This is an overloaded function.

Draws the pie defined by the rectangle commencement at (10, y) with the specified width and height, and the given startAngle and spanAngle.

void QPainter::drawPie(const QRect &rectangle, int startAngle, int spanAngle)

This is an overloaded role.

Draws a pie divers by the given rectangle, startAngle and and spanAngle.

void QPainter::drawPixmap(const QRectF &target, const QPixmap &pixmap, const QRectF &source)

Draws the rectangular portion source of the given pixmap into the given target in the pigment device.

Note: The pixmap is scaled to fit the rectangle, if both the pixmap and rectangle size disagree.

            QRectF            target(10.0            ,            xx.0            ,            80.0            ,            60.0);            QRectF            source(0.0            ,            0.0            ,            lxx.0            ,            40.0);            QPixmap            pixmap(":myPixmap.png");            QPainter(this); painter.drawPixmap(target,            pixmap,            source);

If pixmap is a QBitmap it is drawn with the bits that are "ready" using the pens colour. If backgroundMode is Qt::OpaqueMode, the "unset" $.25 are fatigued using the color of the background brush; if backgroundMode is Qt::TransparentMode, the "unset" bits are transparent. Drawing bitmaps with gradient or texture colors is not supported.

See also drawImage() and QPixmap::devicePixelRatio().

void QPainter::drawPixmap(const QRect &target, const QPixmap &pixmap, const QRect &source)

This is an overloaded function.

Draws the rectangular portion source of the given pixmap into the given target in the paint device.

Annotation: The pixmap is scaled to fit the rectangle, if both the pixmap and rectangle size disagree.

void QPainter::drawPixmap(int x, int y, int w, int h, const QPixmap &pixmap, int sx, int sy, int sw, int sh)

This is an overloaded function.

Draws the rectangular portion with the origin (sx, sy), width sw and height sh, of the given pixmap , at the signal (10, y), with a width of w and a peak of h. If sw or sh are equal to nix the width/tiptop of the pixmap is used and adjusted past the offset sx/sy;

void QPainter::drawPixmap(int x, int y, const QPixmap &pixmap, int sx, int sy, int sw, int sh)

This is an overloaded office.

Draws a pixmap at (ten, y) by copying a role of the given pixmap into the pigment device.

(x, y) specifies the top-left betoken in the pigment device that is to be drawn onto. (sx, sy) specifies the superlative-left point in pixmap that is to exist fatigued. The default is (0, 0).

(sw, sh) specifies the size of the pixmap that is to be drawn. The default, (0, 0) (and negative) ways all the way to the bottom-right of the pixmap.

void QPainter::drawPixmap(const QPointF &point, const QPixmap &pixmap, const QRectF &source)

This is an overloaded function.

Draws the rectangular portion source of the given pixmap with its origin at the given point.

void QPainter::drawPixmap(const QPoint &betoken, const QPixmap &pixmap, const QRect &source)

This is an overloaded function.

Draws the rectangular portion source of the given pixmap with its origin at the given signal.

void QPainter::drawPixmap(const QPointF &point, const QPixmap &pixmap)

This is an overloaded function.

Draws the given pixmap with its origin at the given betoken.

void QPainter::drawPixmap(const QPoint &betoken, const QPixmap &pixmap)

This is an overloaded function.

Draws the given pixmap with its origin at the given bespeak.

void QPainter::drawPixmap(int ten, int y, const QPixmap &pixmap)

This is an overloaded function.

Draws the given pixmap at position (x, y).

void QPainter::drawPixmap(const QRect &rectangle, const QPixmap &pixmap)

This is an overloaded function.

Draws the given pixmap into the given rectangle.

Notation: The pixmap is scaled to fit the rectangle, if both the pixmap and rectangle size disagree.

void QPainter::drawPixmap(int x, int y, int width, int superlative, const QPixmap &pixmap)

This is an overloaded role.

Draws the pixmap into the rectangle at position (x, y) with the given width and height.

void QPainter::drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, QPainter::PixmapFragmentHints hints = PixmapFragmentHints())

This function is used to draw pixmap, or a sub-rectangle of pixmap, at multiple positions with different scale, rotation and opacity. fragments is an array of fragmentCount elements specifying the parameters used to draw each pixmap fragment. The hints parameter can be used to pass in drawing hints.

This function is potentially faster than multiple calls to drawPixmap(), since the backend can optimize country changes.

This function was introduced in Qt 4.7.

See also QPainter::PixmapFragment and QPainter::PixmapFragmentHint.

void QPainter::drawPoint(const QPointF &position)

Draws a single point at the given position using the current pen's colour.

See as well Coordinate System.

void QPainter::drawPoint(const QPoint &position)

This is an overloaded office.

Draws a single point at the given position using the current pen's color.

void QPainter::drawPoint(int x, int y)

This is an overloaded function.

Draws a single betoken at position (x, y).

void QPainter::drawPoints(const QPointF *points, int pointCount)

Draws the start pointCount points in the assortment points using the current pen's color.

Encounter besides Coordinate System.

void QPainter::drawPoints(const QPolygonF &points)

This is an overloaded function.

Draws the points in the vector points.

void QPainter::drawPoints(const QPoint *points, int pointCount)

This is an overloaded function.

Draws the first pointCount points in the array points using the current pen's color.

void QPainter::drawPoints(const QPolygon &points)

This is an overloaded function.

Draws the points in the vector points.

void QPainter::drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule = Qt::OddEvenFill)

Draws the polygon defined by the first pointCount points in the assortment points using the current pen and castor.

The get-go betoken is implicitly connected to the last bespeak, and the polygon is filled with the current brush().

If fillRule is Qt::WindingFill, the polygon is filled using the winding fill algorithm. If fillRule is Qt::OddEvenFill, the polygon is filled using the odd-fifty-fifty fill algorithm. Encounter Qt::FillRule for a more detailed description of these fill up rules.

Come across also drawConvexPolygon(), drawPolyline(), and Coordinate System.

void QPainter::drawPolygon(const QPolygonF &points, Qt::FillRule fillRule = Qt::OddEvenFill)

This is an overloaded function.

Draws the polygon defined by the given points using the fill rule fillRule.

void QPainter::drawPolygon(const QPoint *points, int pointCount, Qt::FillRule fillRule = Qt::OddEvenFill)

This is an overloaded office.

Draws the polygon defined by the first pointCount points in the array points.

void QPainter::drawPolygon(const QPolygon &points, Qt::FillRule fillRule = Qt::OddEvenFill)

This is an overloaded part.

Draws the polygon defined by the given points using the make full rule fillRule.

void QPainter::drawPolyline(const QPointF *points, int pointCount)

Draws the polyline defined by the showtime pointCount points in points using the current pen.

Notation that dissimilar the drawPolygon() part the last bespeak is non connected to the offset, neither is the polyline filled.

Come across too drawLines(), drawPolygon(), and Coordinate System.

void QPainter::drawPolyline(const QPolygonF &points)

This is an overloaded function.

Draws the polyline defined past the given points using the current pen.

void QPainter::drawPolyline(const QPoint *points, int pointCount)

This is an overloaded role.

Draws the polyline defined past the commencement pointCount points in points using the current pen.

void QPainter::drawPolyline(const QPolygon &points)

This is an overloaded function.

Draws the polyline defined by the given points using the current pen.

void QPainter::drawRect(const QRectF &rectangle)

Draws the electric current rectangle with the current pen and castor.

A filled rectangle has a size of rectangle.size(). A stroked rectangle has a size of rectangle.size() plus the pen width.

                    QRectF                    rectangle(10.0                    ,                    twenty.0                    ,                    80.0                    ,                    threescore.0);                    QPainter                    painter(this); painter.drawRect(rectangle);

See also drawRects(), drawPolygon(), and Coordinate System.

void QPainter::drawRect(int ten, int y, int width, int elevation)

This is an overloaded function.

Draws a rectangle with upper left corner at (x, y) and with the given width and tiptop.

void QPainter::drawRect(const QRect &rectangle)

This is an overloaded function.

Draws the current rectangle with the current pen and brush.

void QPainter::drawRects(const QRectF *rectangles, int rectCount)

Draws the start rectCount of the given rectangles using the current pen and castor.

Meet as well drawRect().

void QPainter::drawRects(const QVector<QRectF> &rectangles)

This is an overloaded role.

Draws the given rectangles using the electric current pen and brush.

void QPainter::drawRects(const QRect *rectangles, int rectCount)

This is an overloaded office.

Draws the first rectCount of the given rectangles using the current pen and brush.

void QPainter::drawRects(const QVector<QRect> &rectangles)

This is an overloaded function.

Draws the given rectangles using the current pen and brush.

void QPainter::drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode = Qt::AbsoluteSize)

Draws the given rectangle rect with rounded corners.

The xRadius and yRadius arguments specify the radii of the ellipses defining the corners of the rounded rectangle. When way is Qt::RelativeSize, xRadius and yRadius are specified in per centum of half the rectangle's width and height respectively, and should be in the range 0.0 to 100.0.

A filled rectangle has a size of rect.size(). A stroked rectangle has a size of rect.size() plus the pen width.

                    QRectF                    rectangle(10.0                    ,                    20.0                    ,                    lxxx.0                    ,                    60.0);                    QPainter                    painter(this); painter.drawRoundedRect(rectangle,                    20.0                    ,                    15.0);

This part was introduced in Qt iv.4.

Encounter also drawRect() and QPen.

void QPainter::drawRoundedRect(int x, int y, int w, int h, qreal xRadius, qreal yRadius, Qt::SizeMode mode = Qt::AbsoluteSize)

This is an overloaded function.

Draws the given rectangle ten, y, westward, h with rounded corners.

This role was introduced in Qt four.4.

void QPainter::drawRoundedRect(const QRect &rect, qreal xRadius, qreal yRadius, Qt::SizeMode way = Qt::AbsoluteSize)

This is an overloaded function.

Draws the given rectangle rect with rounded corners.

This role was introduced in Qt 4.4.

void QPainter::drawStaticText(const QPointF &topLeftPosition, const QStaticText &staticText)

Draws the given staticText at the given topLeftPosition.

The text will be fatigued using the font and the transformation assault the painter. If the font and/or transformation attack the painter are different from the ones used to initialize the layout of the QStaticText, then the layout will have to be recalculated. Use QStaticText::gear up() to initialize staticText with the font and transformation with which it will afterwards exist drawn.

If topLeftPosition is not the same equally when staticText was initialized, or when it was last fatigued, then in that location will exist a slight overhead when translating the text to its new position.

Notation: If the painter'southward transformation is not affine, then staticText volition be drawn using regular calls to drawText(), losing any potential for performance improvement.

Note: The y-position is used equally the top of the font.

This function was introduced in Qt 4.7.

See also QStaticText.

void QPainter::drawStaticText(const QPoint &topLeftPosition, const QStaticText &staticText)

This is an overloaded function.

Draws the staticText at the topLeftPosition.

Note: The y-position is used as the top of the font.

This function was introduced in Qt 4.7.

void QPainter::drawStaticText(int left, int top, const QStaticText &staticText)

This is an overloaded office.

Draws the staticText at coordinates left and top.

Note: The y-position is used equally the top of the font.

This function was introduced in Qt 4.vii.

void QPainter::drawText(const QRectF &rectangle, int flags, const QString &text, QRectF *boundingRect = nullptr)

This is an overloaded function.

Draws the given text within the provided rectangle. The rectangle along with alignment flags defines the anchors for the text.

                    QPainter                    painter(this); painter.drawText(rect,                    Qt                    ::AlignCenter,                    tr("Qt\nProject"));

The boundingRect (if non null) is set to what the bounding rectangle should be in guild to enclose the whole text. For example, in the post-obit paradigm, the dotted line represents boundingRect every bit calculated by the function, and the dashed line represents rectangle:

                    QPainter                    painter(this);                    QFont                    font                    =                    painter.font(); font.setPixelSize(48); painter.setFont(font);                    const                    QRect                    rectangle                    =                    QRect(0                    ,                    0                    ,                    100                    ,                    50);                    QRect                    boundingRect; painter.drawText(rectangle,                    0                    ,                    tr("Hello"),                    &boundingRect);                    QPen                    pen                    =                    painter.pen(); pen.setStyle(Qt                    ::DotLine); painter.setPen(pen); painter.drawRect(boundingRect.adapted(0                    ,                    0                    ,                    -pen.width(),                    -pen.width()));  pen.setStyle(Qt                    ::DashLine); painter.setPen(pen); painter.drawRect(rectangle.adjusted(0                    ,                    0                    ,                    -pen.width(),                    -pen.width()));

The flags argument is a bitwise OR of the following flags:

  • Qt::AlignLeft
  • Qt::AlignRight
  • Qt::AlignHCenter
  • Qt::AlignJustify
  • Qt::AlignTop
  • Qt::AlignBottom
  • Qt::AlignVCenter
  • Qt::AlignCenter
  • Qt::TextDontClip
  • Qt::TextSingleLine
  • Qt::TextExpandTabs
  • Qt::TextShowMnemonic
  • Qt::TextWordWrap
  • Qt::TextIncludeTrailingSpaces

By default, QPainter draws text anti-aliased.

Notation: The y-coordinate of rectangle is used as the summit of the font.

See also Qt::AlignmentFlag, Qt::TextFlag, boundingRect(), and layoutDirection().

void QPainter::drawText(const QPointF &position, const QString &text)

Draws the given text with the currently divers text direction, beginning at the given position.

This function does not handle the newline graphic symbol (\northward), as it cannot intermission text into multiple lines, and information technology cannot brandish the newline grapheme. Utilize the QPainter::drawText() overload that takes a rectangle instead if you want to draw multiple lines of text with the newline character, or if you lot want the text to be wrapped.

By default, QPainter draws text anti-aliased.

Note: The y-position is used as the baseline of the font.

Run across besides setFont() and setPen().

void QPainter::drawText(const QPoint &position, const QString &text)

This is an overloaded function.

Draws the given text with the currently divers text management, outset at the given position.

By default, QPainter draws text anti-aliased.

Note: The y-position is used as the baseline of the font.

Encounter also setFont() and setPen().

void QPainter::drawText(int x, int y, const QString &text)

This is an overloaded function.

Draws the given text at position (x, y), using the painter's currently defined text direction.

By default, QPainter draws text anti-aliased.

Notation: The y-position is used as the baseline of the font.

See as well setFont() and setPen().

void QPainter::drawText(const QRect &rectangle, int flags, const QString &text, QRect *boundingRect = nullptr)

This is an overloaded function.

Draws the given text within the provided rectangle according to the specified flags.

The boundingRect (if not null) is prepare to the what the bounding rectangle should be in order to enclose the whole text. For example, in the following prototype, the dotted line represents boundingRect equally calculated past the function, and the dashed line represents rectangle:

                    QPainter                    painter(this);                    QFont                    font                    =                    painter.font(); font.setPixelSize(48); painter.setFont(font);                    const                    QRect                    rectangle                    =                    QRect(0                    ,                    0                    ,                    100                    ,                    50);                    QRect                    boundingRect; painter.drawText(rectangle,                    0                    ,                    tr("Howdy"),                    &boundingRect);                    QPen                    pen                    =                    painter.pen(); pen.setStyle(Qt                    ::DotLine); painter.setPen(pen); painter.drawRect(boundingRect.adjusted(0                    ,                    0                    ,                    -pen.width(),                    -pen.width()));  pen.setStyle(Qt                    ::DashLine); painter.setPen(pen); painter.drawRect(rectangle.adjusted(0                    ,                    0                    ,                    -pen.width(),                    -pen.width()));

By default, QPainter draws text anti-aliased.

Annotation: The y-coordinate of rectangle is used as the peak of the font.

See as well setFont() and setPen().

void QPainter::drawText(int x, int y, int width, int height, int flags, const QString &text, QRect *boundingRect = nullptr)

This is an overloaded function.

Draws the given text inside the rectangle with origin (x, y), width and height.

The boundingRect (if not zip) is gear up to the what the bounding rectangle should be in club to enclose the whole text. For example, in the following paradigm, the dotted line represents boundingRect as calculated by the office, and the dashed line represents the rectangle defined by ten, y, width and height:

                    QPainter                    painter(this);                    QFont                    font                    =                    painter.font(); font.setPixelSize(48); painter.setFont(font);                    const                    QRect                    rectangle                    =                    QRect(0                    ,                    0                    ,                    100                    ,                    50);                    QRect                    boundingRect; painter.drawText(rectangle,                    0                    ,                    tr("Hullo"),                    &boundingRect);                    QPen                    pen                    =                    painter.pen(); pen.setStyle(Qt                    ::DotLine); painter.setPen(pen); painter.drawRect(boundingRect.adjusted(0                    ,                    0                    ,                    -pen.width(),                    -pen.width()));  pen.setStyle(Qt                    ::DashLine); painter.setPen(pen); painter.drawRect(rectangle.adapted(0                    ,                    0                    ,                    -pen.width(),                    -pen.width()));

The flags statement is a bitwise OR of the post-obit flags:

  • Qt::AlignLeft
  • Qt::AlignRight
  • Qt::AlignHCenter
  • Qt::AlignJustify
  • Qt::AlignTop
  • Qt::AlignBottom
  • Qt::AlignVCenter
  • Qt::AlignCenter
  • Qt::TextSingleLine
  • Qt::TextExpandTabs
  • Qt::TextShowMnemonic
  • Qt::TextWordWrap

By default, QPainter draws text anti-aliased.

Note: The y-position is used as the top of the font.

See likewise Qt::AlignmentFlag, Qt::TextFlag, setFont(), and setPen().

void QPainter::drawText(const QRectF &rectangle, const QString &text, const QTextOption &option = QTextOption())

This is an overloaded function.

Draws the given text in the rectangle specified using the option to control its positioning, direction, and orientation. The options given in option override those set on the QPainter object itself.

By default, QPainter draws text anti-aliased.

Note: The y-coordinate of rectangle is used equally the meridian of the font.

Run into besides setFont() and setPen().

void QPainter::drawTiledPixmap(const QRectF &rectangle, const QPixmap &pixmap, const QPointF &position = QPointF())

Draws a tiled pixmap, inside the given rectangle with its origin at the given position.

Calling drawTiledPixmap() is similar to calling drawPixmap() several times to fill (tile) an surface area with a pixmap, merely is potentially much more than efficient depending on the underlying window organisation.

drawTiledPixmap() will produce the same visual tiling pattern on high-dpi displays (with devicePixelRatio > 1), compared to normal- dpi displays. Ready the devicePixelRatio on the pixmap to control the tile size. For example, setting it to 2 halves the tile width and meridian (on both 1x and 2x displays), and produces high-resolution output on 2x displays.

The position offset is e'er in the painter coordinate organization, indepentent of display devicePixelRatio.

Run across also drawPixmap().

void QPainter::drawTiledPixmap(int x, int y, int width, int acme, const QPixmap &pixmap, int sx = 0, int sy = 0)

This is an overloaded office.

Draws a tiled pixmap in the specified rectangle.

(ten, y) specifies the acme-left indicate in the pigment device that is to be drawn onto; with the given width and top. (sx, sy) specifies the top-left point in the pixmap that is to be drawn; this defaults to (0, 0).

void QPainter::drawTiledPixmap(const QRect &rectangle, const QPixmap &pixmap, const QPoint &position = QPoint())

This is an overloaded part.

Draws a tiled pixmap, within the given rectangle with its origin at the given position.

bool QPainter::terminate()

Ends painting. Any resources used while painting are released. Y'all don't normally need to call this since it is called by the destructor.

Returns truthful if the painter is no longer agile; otherwise returns imitation.

See also begin() and isActive().

void QPainter::endNativePainting()

Restores the painter after manually issuing native painting commands. Lets the painter restore whatever native land that it relies on before calling whatsoever other painter commands.

This function was introduced in Qt 4.vi.

See also beginNativePainting().

void QPainter::eraseRect(const QRectF &rectangle)

Erases the area within the given rectangle. Equivalent to calling

            fillRect(rectangle,            groundwork()).          

Run into as well fillRect().

void QPainter::eraseRect(int x, int y, int width, int height)

This is an overloaded role.

Erases the area inside the rectangle beginning at (10, y) with the given width and elevation.

void QPainter::eraseRect(const QRect &rectangle)

This is an overloaded office.

Erases the area inside the given rectangle.

void QPainter::fillPath(const QPainterPath &path, const QBrush &brush)

Fills the given path using the given brush. The outline is not fatigued.

Alternatively, you can specify a QColor instead of a QBrush; the QBrush constructor (taking a QColor argument) volition automatically create a solid pattern brush.

Run into also drawPath().

void QPainter::fillRect(const QRectF &rectangle, const QBrush &brush)

Fills the given rectangle with the brush specified.

Alternatively, you can specify a QColor instead of a QBrush; the QBrush constructor (taking a QColor argument) volition automatically create a solid design brush.

Come across also drawRect().

void QPainter::fillRect(int x, int y, int width, int height, const QBrush &castor)

This is an overloaded office.

Fills the rectangle beginning at (x, y) with the given width and height, using the given brush.

void QPainter::fillRect(const QRect &rectangle, const QBrush &brush)

This is an overloaded function.

Fills the given rectangle with the specified brush.

void QPainter::fillRect(const QRectF &rectangle, const QColor &colour)

This is an overloaded function.

Fills the given rectangle with the color specified.

This role was introduced in Qt iv.v.

void QPainter::fillRect(int x, int y, int width, int height, const QColor &color)

This is an overloaded function.

Fills the rectangle beginning at (x, y) with the given width and height, using the given color.

This function was introduced in Qt 4.5.

void QPainter::fillRect(const QRect &rectangle, const QColor &color)

This is an overloaded part.

Fills the given rectangle with the color specified.

This role was introduced in Qt 4.v.

void QPainter::fillRect(int ten, int y, int width, int height, Qt::GlobalColor color)

This is an overloaded role.

Fills the rectangle starting time at (ten, y) with the given width and peak, using the given color.

This part was introduced in Qt 4.v.

void QPainter::fillRect(const QRect &rectangle, Qt::GlobalColor color)

This is an overloaded function.

Fills the given rectangle with the specified color.

This function was introduced in Qt 4.five.

void QPainter::fillRect(const QRectF &rectangle, Qt::GlobalColor color)

This is an overloaded part.

Fills the given rectangle with the specified color.

This function was introduced in Qt four.5.

void QPainter::fillRect(int 10, int y, int width, int summit, Qt::BrushStyle way)

This is an overloaded function.

Fills the rectangle showtime at (x, y) with the given width and height, using the castor way specified.

This function was introduced in Qt iv.v.

void QPainter::fillRect(const QRect &rectangle, Qt::BrushStyle manner)

This is an overloaded function.

Fills the given rectangle with the brush style specified.

This role was introduced in Qt four.5.

void QPainter::fillRect(const QRectF &rectangle, Qt::BrushStyle style)

This is an overloaded function.

Fills the given rectangle with the brush manner specified.

This office was introduced in Qt iv.5.

void QPainter::fillRect(int ten, int y, int width, int superlative, QGradient::Preset preset)

This is an overloaded function.

Fills the rectangle beginning at (x, y) with the given width and pinnacle, using the given gradient preset.

This role was introduced in Qt 5.12.

void QPainter::fillRect(const QRect &rectangle, QGradient::Preset preset)

This is an overloaded function.

Fills the given rectangle with the specified gradient preset.

This function was introduced in Qt 5.12.

void QPainter::fillRect(const QRectF &rectangle, QGradient::Preset preset)

This is an overloaded function.

Fills the given rectangle with the specified gradient preset.

This function was introduced in Qt 5.12.

const QFont &QPainter::font() const

Returns the currently ready font used for drawing text.

Run across also setFont(), drawText(), and Settings.

QFontInfo QPainter::fontInfo() const

Returns the font info for the painter if the painter is active. Otherwise, the return value is undefined.

Come across also font(), isActive(), and Settings.

QFontMetrics QPainter::fontMetrics() const

Returns the font metrics for the painter if the painter is agile. Otherwise, the render value is undefined.

Run into too font(), isActive(), and Settings.

bool QPainter::hasClipping() const

Returns truthful if clipping has been gear up; otherwise returns simulated.

Run across also setClipping() and Clipping.

bool QPainter::isActive() const

Returns true if begin() has been called and terminate() has not yet been called; otherwise returns faux.

See also begin() and QPaintDevice::paintingActive().

Qt::LayoutDirection QPainter::layoutDirection() const

Returns the layout direction used past the painter when cartoon text.

See besides QTextOption::textDirection(), setLayoutDirection(), drawText(), and Settings.

qreal QPainter::opacity() const

Returns the opacity of the painter. The default value is 1.

This office was introduced in Qt 4.2.

Run into as well setOpacity().

QPaintEngine *QPainter::paintEngine() const

Returns the paint engine that the painter is currently operating on if the painter is active; otherwise 0.

See also isActive().

const QPen &QPainter::pen() const

Returns the painter'southward electric current pen.

See also setPen() and Settings.

QPainter::RenderHints QPainter::renderHints() const

Returns a flag that specifies the rendering hints that are ready for this painter.

Run into as well setRenderHints(), testRenderHint(), and Rendering Quality.

void QPainter::resetTransform()

Resets any transformations that were made using translate(), scale(), shear(), rotate(), setWorldTransform(), setViewport() and setWindow().

See too Coordinate Transformations.

void QPainter::restore()

Restores the current painter country (pops a saved state off the stack).

See also save().

void QPainter::rotate(qreal bending)

Rotates the coordinate arrangement clockwise. The given bending parameter is in degrees.

See besides setWorldTransform() and Coordinate Transformations.

void QPainter::salvage()

Saves the current painter state (pushes the state onto a stack). A salve() must be followed by a respective restore(); the end() role unwinds the stack.

See also restore().

void QPainter::calibration(qreal sx, qreal sy)

Scales the coordinate organisation by (sx, sy).

Run across too setWorldTransform() and Coordinate Transformations.

void QPainter::setBackground(const QBrush &brush)

Sets the groundwork brush of the painter to the given brush.

The groundwork brush is the brush that is filled in when cartoon opaque text, stippled lines and bitmaps. The background brush has no consequence in transparent background way (which is the default).

See too background(), setBackgroundMode(), and Settings.

void QPainter::setBackgroundMode(Qt::BGMode mode)

Sets the background way of the painter to the given mode

Qt::TransparentMode (the default) draws stippled lines and text without setting the background pixels. Qt::OpaqueMode fills these space with the current background color.

Note that in order to describe a bitmap or pixmap transparently, you lot must use QPixmap::setMask().

See besides backgroundMode(), setBackground(), and Settings.

void QPainter::setBrush(const QBrush &brush)

Sets the painter'south castor to the given brush.

The painter'due south castor defines how shapes are filled.

Meet as well brush() and Settings.

void QPainter::setBrush(Qt::BrushStyle style)

This is an overloaded function.

Sets the painter'south castor to black color and the specified manner.

void QPainter::setBrushOrigin(const QPointF &position)

Sets the brush origin to position.

The brush origin specifies the (0, 0) coordinate of the painter's brush.

Note that while the brushOrigin() was necessary to prefer the parent's background for a widget in Qt 3, this is no longer the case since the Qt iv painter doesn't paint the background unless yous explicitly tell it to exercise so by setting the widget's autoFillBackground holding to true.

Meet also brushOrigin() and Settings.

void QPainter::setBrushOrigin(int 10, int y)

This is an overloaded function.

Sets the brush's origin to betoken (x, y).

void QPainter::setBrushOrigin(const QPoint &position)

This is an overloaded office.

Sets the brush's origin to the given position.

void QPainter::setClipPath(const QPainterPath &path, Qt::ClipOperation operation = Qt::ReplaceClip)

Enables clipping, and sets the clip path for the painter to the given path, with the clip operation.

Note that the prune path is specified in logical (painter) coordinates.

See also clipPath(), clipRegion(), and Clipping.

void QPainter::setClipRect(const QRectF &rectangle, Qt::ClipOperation operation = Qt::ReplaceClip)

Enables clipping, and sets the clip region to the given rectangle using the given clip operation. The default operation is to supplant the electric current clip rectangle.

Annotation that the clip rectangle is specified in logical (painter) coordinates.

Meet also clipRegion(), setClipping(), and Clipping.

void QPainter::setClipRect(const QRect &rectangle, Qt::ClipOperation operation = Qt::ReplaceClip)

This is an overloaded function.

Enables clipping, and sets the clip region to the given rectangle using the given clip performance.

void QPainter::setClipRect(int x, int y, int width, int height, Qt::ClipOperation operation = Qt::ReplaceClip)

Enables clipping, and sets the clip region to the rectangle beginning at (ten, y) with the given width and height.

void QPainter::setClipRegion(const QRegion &region, Qt::ClipOperation operation = Qt::ReplaceClip)

Sets the prune region to the given region using the specified clip operation. The default prune functioning is to supercede the current clip region.

Note that the clip region is given in logical coordinates.

See also clipRegion(), setClipRect(), and Clipping.

void QPainter::setClipping(bool enable)

Enables clipping if enable is true, or disables clipping if enable is false.

See likewise hasClipping() and Clipping.

void QPainter::setCompositionMode(QPainter::CompositionMode style)

Sets the composition mode to the given mode.

Alarm: Just a QPainter operating on a QImage fully supports all composition modes. The RasterOp modes are supported for X11 as described in compositionMode().

See besides compositionMode().

void QPainter::setFont(const QFont &font)

Sets the painter'southward font to the given font.

This font is used by subsequent drawText() functions. The text color is the same equally the pen color.

If you set a font that isn't available, Qt finds a close match. font() volition return what you gear up using setFont() and fontInfo() returns the font actually beingness used (which may be the same).

Run into also font(), drawText(), and Settings.

void QPainter::setLayoutDirection(Qt::LayoutDirection direction)

Sets the layout direction used by the painter when cartoon text, to the specified direction.

The default is Qt::LayoutDirectionAuto, which will implicitly decide the direction from the text drawn.

Come across also QTextOption::setTextDirection(), layoutDirection(), drawText(), and Settings.

void QPainter::setOpacity(qreal opacity)

Sets the opacity of the painter to opacity. The value should exist in the range 0.0 to 1.0, where 0.0 is fully transparent and 1.0 is fully opaque.

Opacity assault the painter will apply to all drawing operations individually.

This function was introduced in Qt four.2.

See likewise opacity().

void QPainter::setPen(const QPen &pen)

Sets the painter's pen to be the given pen.

The pen defines how to draw lines and outlines, and it also defines the text color.

See likewise pen() and Settings.

void QPainter::setPen(const QColor &color)

This is an overloaded office.

Sets the painter's pen to have fashion Qt::SolidLine, width 1 and the specified color.

void QPainter::setPen(Qt::PenStyle mode)

This is an overloaded function.

Sets the painter's pen to take the given style, width one and blackness color.

void QPainter::setRenderHint(QPainter::RenderHint hint, bool on = truthful)

Sets the given render hint on the painter if on is true; otherwise clears the render hint.

Come across also setRenderHints(), renderHints(), and Rendering Quality.

void QPainter::setRenderHints(QPainter::RenderHints hints, bool on = true)

Sets the given return hints on the painter if on is truthful; otherwise clears the render hints.

This function was introduced in Qt 4.ii.

See also setRenderHint(), renderHints(), and Rendering Quality.

void QPainter::setTransform(const QTransform &transform, bool combine = imitation)

Sets the world transformation matrix. If combine is true, the specified transform is combined with the current matrix; otherwise it replaces the current matrix.

This function was introduced in Qt 4.iii.

See also transform() and setWorldTransform().

void QPainter::setViewTransformEnabled(bool enable)

Enables view transformations if enable is true, or disables view transformations if enable is simulated.

Encounter also viewTransformEnabled() and Window-Viewport Conversion.

void QPainter::setViewport(const QRect &rectangle)

Sets the painter's viewport rectangle to the given rectangle, and enables view transformations.

The viewport rectangle is function of the view transformation. The viewport specifies the device coordinate system. Its sister, the window(), specifies the logical coordinate arrangement.

The default viewport rectangle is the same as the device's rectangle.

Run into also viewport(), viewTransformEnabled(), and Window-Viewport Conversion.

void QPainter::setViewport(int 10, int y, int width, int height)

This is an overloaded function.

Sets the painter's viewport rectangle to be the rectangle beginning at (x, y) with the given width and height.

void QPainter::setWindow(const QRect &rectangle)

Sets the painter's window to the given rectangle, and enables view transformations.

The window rectangle is part of the view transformation. The window specifies the logical coordinate system. Its sister, the viewport(), specifies the device coordinate arrangement.

The default window rectangle is the same equally the device's rectangle.

Run across also window(), viewTransformEnabled(), and Window-Viewport Conversion.

void QPainter::setWindow(int 10, int y, int width, int height)

This is an overloaded office.

Sets the painter'due south window to the rectangle get-go at (x, y) and the given width and height.

void QPainter::setWorldMatrixEnabled(bool enable)

Enables transformations if enable is true, or disables transformations if enable is false. The world transformation matrix is not changed.

This office was introduced in Qt 4.ii.

See also worldMatrixEnabled(), worldTransform(), and Coordinate Transformations.

void QPainter::setWorldTransform(const QTransform &matrix, bool combine = fake)

Sets the world transformation matrix. If combine is true, the specified matrix is combined with the current matrix; otherwise it replaces the electric current matrix.

See as well worldTransform(), transform(), and setTransform().

void QPainter::shear(qreal sh, qreal sv)

Shears the coordinate system past (sh, sv).

See also setWorldTransform() and Coordinate Transformations.

void QPainter::strokePath(const QPainterPath &path, const QPen &pen)

Draws the outline (strokes) the path path with the pen specified by pen

See besides fillPath() and Drawing.

bool QPainter::testRenderHint(QPainter::RenderHint hint) const

Returns true if hint is gear up; otherwise returns false.

This role was introduced in Qt 4.iii.

See also renderHints() and setRenderHint().

const QTransform &QPainter::transform() const

Alias for worldTransform(). Returns the globe transformation matrix.

See also setTransform() and worldTransform().

void QPainter::translate(const QPointF &offset)

Translates the coordinate system by the given offset; i.e. the given offset is added to points.

See likewise setWorldTransform() and Coordinate Transformations.

void QPainter::translate(const QPoint &starting time)

This is an overloaded function.

Translates the coordinate system by the given starting time.

void QPainter::translate(qreal dx, qreal dy)

This is an overloaded function.

Translates the coordinate organization past the vector (dx, dy).

bool QPainter::viewTransformEnabled() const

Returns true if view transformation is enabled; otherwise returns false.

See as well setViewTransformEnabled() and worldTransform().

QRect QPainter::viewport() const

Returns the viewport rectangle.

See as well setViewport() and setViewTransformEnabled().

QRect QPainter::window() const

Returns the window rectangle.

Come across as well setWindow() and setViewTransformEnabled().

bool QPainter::worldMatrixEnabled() const

Returns true if globe transformation is enabled; otherwise returns false.

This role was introduced in Qt 4.2.

Come across also setWorldMatrixEnabled(), worldTransform(), and Coordinate System.

const QTransform &QPainter::worldTransform() const

Returns the world transformation matrix.

Run across likewise setWorldTransform().

mcbrydejoher1959.blogspot.com

Source: https://doc.qt.io/qt-5/qpainter.html