QtBase
v6.3.1
|
The QPainter class performs low-level painting on widgets and other paint devices. More...
#include <qpainter.h>
Classes | |
class | PixmapFragment |
This class is used in conjunction with the QPainter::drawPixmapFragments() function to specify how a pixmap, or sub-rect of a pixmap, is drawn. More... | |
Friends | |
class | QWidget |
class | QFontEngine |
class | QFontEngineBox |
class | QFontEngineFT |
class | QFontEngineMac |
class | QFontEngineWin |
class | QPaintEngine |
class | QPaintEngineExPrivate |
class | QOpenGLPaintEngine |
class | QWin32PaintEngine |
class | QWin32PaintEnginePrivate |
class | QRasterPaintEngine |
class | QAlphaPaintEngine |
class | QPreviewPaintEngine |
class | QTextEngine |
The QPainter class performs low-level painting on widgets and other paint devices.
\inmodule QtGui
\reentrant
QPainter provides highly optimized functions to do most of the drawing GUI programs require. It can draw everything from simple lines to complex shapes like pies and chords. It can also draw aligned text and pixmaps. Normally, it draws in a "natural" coordinate system, but it can also do view and world transformation. QPainter can operate on any object that inherits the QPaintDevice class.
The common use of QPainter is inside a widget's paint event: Construct and customize (e.g. set the pen or the brush) the painter. Then draw. Remember to destroy the QPainter object after drawing. For example:
The core functionality of QPainter is drawing, but the class also provide several functions that allows you to customize QPainter's settings and its rendering quality, and others that enable clipping. In addition you can control how different shapes are merged together by specifying the painter's composition mode.
The isActive() function indicates whether the painter is active. A painter is activated by the begin() function and the constructor that takes a QPaintDevice argument. The end() function, and the destructor, deactivates it.
Together with the QPaintDevice and QPaintEngine classes, QPainter form the basis for Qt's paint system. QPainter is the class used to perform drawing operations. QPaintDevice represents a device that can be painted on using a QPainter. QPaintEngine provides the interface that the painter uses to draw onto different types of devices. If the painter is active, device() returns the paint device on which the painter paints, and paintEngine() returns the paint engine that the painter is currently operating on. For more information, see the \l {Paint System}.
Sometimes it is desirable to make someone else paint on an unusual QPaintDevice. QPainter supports a static function to do this, setRedirected().
Definition at line 81 of file qpainter.h.
Defines the modes supported for digital image compositing. Composition modes are used to specify how the pixels in one image, the source, are merged with the pixel in another image, the destination.
Please note that the bitwise raster operation modes, denoted with a RasterOp prefix, are only natively supported in the X11 and raster paint engines. This means that the only way to utilize these modes on the Mac is via a QImage. The RasterOp denoted blend modes are not supported for pens and brushes with alpha components. Also, turning on the QPainter::Antialiasing render hint will effectively disable the RasterOp modes.
The most common type is SourceOver (often referred to as just alpha blending) where the source pixel is blended on top of the destination pixel in such a way that the alpha component of the source defines the translucency of the pixel.
Several composition modes require an alpha channel in the source or target images to have an effect. For optimal performance the image format \l {QImage::Format}{Format_ARGB32_Premultiplied} is preferred.
When a composition mode is set it applies to all painting operator, pens, brushes, gradients and pixmap/image drawing.
\value CompositionMode_SourceOver This is the default mode. The alpha of the source is used to blend the pixel on top of the destination.
\value CompositionMode_DestinationOver The alpha of the destination is used to blend it on top of the source pixels. This mode is the inverse of CompositionMode_SourceOver.
\value CompositionMode_Clear The pixels in the destination are cleared (set to fully transparent) independent of the source.
\value CompositionMode_Source The output is the source pixel. (This means a basic copy operation and is identical to SourceOver when the source pixel is opaque).
\value CompositionMode_Destination The output is the destination pixel. This means that the blending has no effect. This mode is the inverse of CompositionMode_Source.
\value CompositionMode_SourceIn The output is the source, where the alpha is reduced by that of the destination.
\value CompositionMode_DestinationIn The output is the destination, where the alpha is reduced by that of the source. This mode is the inverse of CompositionMode_SourceIn.
\value CompositionMode_SourceOut The output is the source, where the alpha is reduced by the inverse of destination.
\value CompositionMode_DestinationOut The output is the destination, where the alpha is reduced by the inverse of the source. This mode is the inverse of CompositionMode_SourceOut.
\value CompositionMode_SourceAtop The source pixel is blended on top of the destination, with the alpha of the source pixel reduced by the alpha of the destination pixel.
\value CompositionMode_DestinationAtop The destination pixel is blended on top of the source, with the alpha of the destination pixel is reduced by the alpha of the destination pixel. This mode is the inverse of CompositionMode_SourceAtop.
\value CompositionMode_Xor The source, whose alpha is reduced with the inverse of the destination alpha, is merged with the destination, whose alpha is reduced by the inverse of the source alpha. CompositionMode_Xor is not the same as the bitwise Xor.
\value CompositionMode_Plus Both the alpha and color of the source and destination pixels are added together.
\value CompositionMode_Multiply The output is the source color multiplied by the destination. Multiplying a color with white leaves the color unchanged, while multiplying a color with black produces black.
\value CompositionMode_Screen The source and destination colors are inverted and then multiplied. Screening a color with white produces white, whereas screening a color with black leaves the color unchanged.
\value CompositionMode_Overlay Multiplies or screens the colors depending on the destination color. The destination color is mixed with the source color to reflect the lightness or darkness of the destination.
\value CompositionMode_Darken The darker of the source and destination colors is selected.
\value CompositionMode_Lighten The lighter of the source and destination colors is selected.
\value CompositionMode_ColorDodge The destination color is brightened to reflect the source color. A black source color leaves the destination color unchanged.
\value CompositionMode_ColorBurn The destination color is darkened to reflect the source color. A white source color leaves the destination color unchanged.
\value CompositionMode_HardLight Multiplies or screens the colors depending on the source color. A light source color will lighten the destination color, whereas a dark source color will darken the destination color.
\value CompositionMode_SoftLight Darkens or lightens the colors depending on the source color. Similar to CompositionMode_HardLight.
\value CompositionMode_Difference Subtracts the darker of the colors from the lighter. Painting with white inverts the destination color, whereas painting with black leaves the destination color unchanged.
\value CompositionMode_Exclusion Similar to CompositionMode_Difference, but with a lower contrast. Painting with white inverts the destination color, whereas painting with black leaves the destination color unchanged.
\value RasterOp_SourceOrDestination Does a bitwise OR operation on the source and destination pixels (src OR dst).
\value RasterOp_SourceAndDestination Does a bitwise AND operation on the source and destination pixels (src AND dst).
\value RasterOp_SourceXorDestination Does a bitwise XOR operation on the source and destination pixels (src XOR dst).
\value RasterOp_NotSourceAndNotDestination Does a bitwise NOR operation on the source and destination pixels ((NOT src) AND (NOT dst)).
\value RasterOp_NotSourceOrNotDestination Does a bitwise NAND operation on the source and destination pixels ((NOT src) OR (NOT dst)).
\value RasterOp_NotSourceXorDestination Does a bitwise operation where the source pixels are inverted and then XOR'ed with the destination ((NOT src) XOR dst).
\value RasterOp_NotSource Does a bitwise operation where the source pixels are inverted (NOT src).
\value RasterOp_NotSourceAndDestination Does a bitwise operation where the source is inverted and then AND'ed with the destination ((NOT src) AND dst).
\value RasterOp_SourceAndNotDestination Does a bitwise operation where the source is AND'ed with the inverted destination pixels (src AND (NOT dst)).
\value RasterOp_NotSourceOrDestination Does a bitwise operation where the source is inverted and then OR'ed with the destination ((NOT src) OR dst).
\value RasterOp_ClearDestination The pixels in the destination are cleared (set to 0) independent of the source.
\value RasterOp_SetDestination The pixels in the destination are set (set to 1) independent of the source.
\value RasterOp_NotDestination Does a bitwise operation where the destination pixels are inverted (NOT dst).
\value RasterOp_SourceOrNotDestination Does a bitwise operation where the source is OR'ed with the inverted destination pixels (src OR (NOT dst)).
Definition at line 132 of file qpainter.h.
the x coordinate of center point in the target rectangle.
\variable QPainter::PixmapFragment::x
\variable QPainter::PixmapFragment::y
the y coordinate of the center point in the target rectangle.
\variable QPainter::PixmapFragment::sourceLeft
the left coordinate of the source rectangle.
\variable QPainter::PixmapFragment::sourceTop
the top coordinate of the source rectangle.
\variable QPainter::PixmapFragment::width
the width of the source rectangle and is used to calculate the width of the target rectangle.
\variable QPainter::PixmapFragment::height
the height of the source rectangle and is used to calculate the height of the target rectangle.
\variable QPainter::PixmapFragment::scaleX
the horizontal scale of the target rectangle.
\variable QPainter::PixmapFragment::scaleY
the vertical scale of the target rectangle.
\variable QPainter::PixmapFragment::rotation
the rotation of the target rectangle in degrees. The target rectangle is rotated after it has been scaled.
\variable QPainter::PixmapFragment::opacity
the opacity of the target rectangle, where 0.0 is fully transparent and 1.0 is fully opaque.
\value OpaqueHint Indicates that the pixmap fragments to be drawn are opaque. Opaque fragments are potentially faster to draw.
Enumerator | |
---|---|
OpaqueHint |
Definition at line 116 of file qpainter.h.
enum QPainter::RenderHint |
Renderhints are used to specify flags to QPainter that may or may not be respected by any given engine.
\value Antialiasing Indicates that the engine should antialias edges of primitives if possible.
\value TextAntialiasing Indicates that the engine should antialias text if possible. To forcibly disable antialiasing for text, do not use this hint. Instead, set QFont::NoAntialias on your font's style strategy.
\value SmoothPixmapTransform Indicates that the engine should use a smooth pixmap transformation algorithm (such as bilinear) rather than nearest neighbor.
\value VerticalSubpixelPositioning Allow text to be positioned at fractions of pixels vertically as well as horizontally, if this is supported by the font engine. This is currently supported by Freetype on all platforms when the hinting preference is QFont::PreferNoHinting, and also on macOS. For most use cases this will not improve visual quality, but may increase memory consumption and some reduction in text rendering performance. Therefore, enabling this is not recommended unless the use case requires it. One such use case could be aligning glyphs with other visual primitives. This value was added in Qt 6.1.
\value LosslessImageRendering Use a lossless image rendering, whenever possible. Currently, this hint is only used when QPainter is employed to output a PDF file through QPrinter or QPdfWriter, where drawImage()/drawPixmap() calls will encode images using a lossless compression algorithm instead of lossy JPEG compression. This value was added in Qt 5.13.
Enumerator | |
---|---|
Antialiasing | |
TextAntialiasing | |
SmoothPixmapTransform | |
VerticalSubpixelPositioning | |
LosslessImageRendering |
Definition at line 87 of file qpainter.h.
QPainter::QPainter | ( | ) |
|
explicit |
Constructs a painter that begins painting the paint device immediately.
This constructor is convenient for short-lived painters, e.g. in a QWidget::paintEvent() and should be used only once. The constructor calls begin() for you and the QPainter destructor automatically calls end().
Here's an example using begin() and 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 end() to paint on external devices, e.g. printers.
Definition at line 1489 of file qpainter.cpp.
QPainter::~QPainter | ( | ) |
Destroys the painter.
Definition at line 1503 of file qpainter.cpp.
Returns the current background brush.
Definition at line 2413 of file qpainter.cpp.
Qt::BGMode QPainter::backgroundMode | ( | ) | const |
Returns the current background mode.
Definition at line 3622 of file qpainter.cpp.
bool QPainter::begin | ( | QPaintDevice * | device | ) |
Begins painting the paint device and returns true
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 can occur are serious problems, such as these:
Note that most of the time, you can use one of the constructors instead of begin(), and that end() is automatically done at destruction.
Definition at line 1709 of file qpainter.cpp.
void QPainter::beginNativePainting | ( | ) |
Flushes the painting pipeline and prepares for the user issuing commands directly to the underlying graphics context. Must be followed by a call to endNativePainting().
Note that only the states the underlying paint engine changes will be reset to their respective default states. The states we reset may change from release to release. The following states are currently reset in the OpenGL 2 engine:
\list
If, for example, the OpenGL polygon mode is changed by the user inside a beginNativePaint()/endNativePainting() block, it will not be reset to the default state by endNativePainting(). Here is an example that shows intermixing of painter commands and raw OpenGL commands:
Definition at line 1967 of file qpainter.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns the bounding rectangle of the text as it will appear when drawn inside the given rectangle with the specified flags using the currently set font().
Definition at line 6334 of file qpainter.cpp.
QRectF QPainter::boundingRect | ( | const QRectF & | rectangle, |
const QString & | text, | ||
const QTextOption & | option = QTextOption() |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Instead of specifying flags as a bitwise OR of the Qt::AlignmentFlag and Qt::TextFlag, this overloaded function takes an option argument. The QTextOption class provides a description of general rich text properties.
Definition at line 6367 of file qpainter.cpp.
Returns the bounding rectangle of the text as it 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 not 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: \list
Definition at line 6345 of file qpainter.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns the bounding rectangle of the given text as it will appear when drawn inside the rectangle beginning at the point ({x}, {y}) with width w and height h.
Definition at line 878 of file qpainter.h.
Returns the painter's current brush.
Definition at line 3813 of file qpainter.cpp.
QPoint QPainter::brushOrigin | ( | ) | const |
Returns the currently set brush origin.
Definition at line 2094 of file qpainter.cpp.
QRectF QPainter::clipBoundingRect | ( | ) | const |
Returns the bounding rectangle of the current clip if there is a clip; otherwise returns an empty rectangle. Note that the clip region is given in logical coordinates.
The bounding rectangle is not guaranteed to be tight.
Definition at line 2661 of file qpainter.cpp.
QPainterPath QPainter::clipPath | ( | ) | const |
Returns the current clip path in logical coordinates.
Definition at line 2610 of file qpainter.cpp.
QRegion QPainter::clipRegion | ( | ) | const |
Returns the currently set clip region. Note that the clip region is given in logical coordinates.
Definition at line 2493 of file qpainter.cpp.
QTransform QPainter::combinedTransform | ( | ) | const |
Returns the transformation matrix combining the current window/viewport and world transformation.
Definition at line 7984 of file qpainter.cpp.
QPainter::CompositionMode QPainter::compositionMode | ( | ) | const |
Returns the current composition mode.
Definition at line 2397 of file qpainter.cpp.
QPaintDevice * QPainter::device | ( | ) | const |
Returns the paint device on which this painter is currently painting, or \nullptr if the painter is not active.
Definition at line 1529 of file qpainter.cpp.
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 do transformations nativly.
The QPaintEngine::PaintEngineFeature enum can be queried to determine whether the platform performs the transformations or not.
Definition at line 7894 of file qpainter.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the arc defined by the given rectangle, startAngle and spanAngle.
Definition at line 633 of file qpainter.h.
Draws the arc defined by the given rectangle, startAngle and spanAngle.
The startAngle and spanAngle must be 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 mean the clockwise direction. Zero degrees is at the 3 o'clock position.
\table 100% \row
Definition at line 4113 of file qpainter.cpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the arc defined by the rectangle beginning at (x, y) with the specified width and height, and the given startAngle and spanAngle.
Definition at line 638 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the chord defined by the given rectangle, startAngle and spanAngle.
Definition at line 653 of file qpainter.h.
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 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 mean the clockwise direction. Zero degrees is at the 3 o'clock position.
\table 100% \row
Definition at line 4244 of file qpainter.cpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the chord defined by the rectangle beginning at (x, y) with the specified width and height, and the given startAngle and spanAngle.
Definition at line 658 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the convex polygon defined by the first pointCount points in the array points using the current pen.
Definition at line 4713 of file qpainter.cpp.
Draws the convex polygon defined by the first pointCount points in the array points using the current pen.
\table 100% \row
The first point is implicitly connected to the last point, and the polygon is filled with the current brush(). If the supplied polygon is not convex, i.e. it contains at least one angle larger than 180 degrees, the results are undefined.
On some platforms (e.g. X11), the drawConvexPolygon() function can be faster than the drawPolygon() function.
Definition at line 4747 of file qpainter.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the convex polygon defined by polygon using the current pen and brush.
Definition at line 549 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the convex polygon defined by polygon using the current pen and brush.
Definition at line 544 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the ellipse positioned at {center} with radii {rx} and {ry}.
Definition at line 628 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the ellipse positioned at {center} with radii {rx} and {ry}.
Definition at line 623 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the ellipse defined by the given rectangle.
Definition at line 4027 of file qpainter.cpp.
Draws the ellipse defined by the given rectangle.
A filled ellipse has a size of {rectangle}.\l {QRect::size()}{size()}. A stroked ellipse has a size of {rectangle}.\l {QRect::size()}{size()} plus the pen width.
\table 100% \row
Definition at line 3986 of file qpainter.cpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the ellipse defined by the rectangle beginning at ({x}, {y}) with the given width and height.
Definition at line 618 of file qpainter.h.
Draws the glyphs represented by glyphs at position. The position gives the edge of the baseline for the string of glyphs. The glyphs will be retrieved from the font selected on glyphs and at offsets given by the positions in glyphs.
Definition at line 5300 of file qpainter.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the given image at the given point.
Definition at line 834 of file qpainter.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the rectangular portion source of the given image with its origin at the given point.
Definition at line 817 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the given image at the given point.
Definition at line 5120 of file qpainter.cpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the rectangular portion source of the given image with its origin at the given point.
Definition at line 811 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the given image into the given rectangle.
Definition at line 829 of file qpainter.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the rectangular portion source of the given image into the target rectangle in the paint device.
Definition at line 805 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the given image into the given rectangle.
Definition at line 824 of file qpainter.h.
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 image into the target rectangle in the paint device.
If the image needs to be modified to fit in a lower-resolution result (e.g. converting from 32-bit to 8-bit), use the flags to specify how you would prefer this to happen.
\table 100% \row
Definition at line 5175 of file qpainter.cpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws an image at ({x}, {y}) by copying a part of image into the paint device.
({x}, {y}) specifies the top-left point in the paint device that is to be drawn onto. ({sx}, {sy}) specifies the top-left point in image that is to be drawn. The default is (0, 0).
({sw}, {sh}) specifies the size of the image that is to be drawn. The default, (0, 0) (and negative) means all the way to the bottom-right of the image.
Definition at line 839 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws a line defined by line.
Definition at line 482 of file qpainter.h.
Draws a line defined by line.
\table 100% \row
Definition at line 477 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws a line from p1 to p2.
Definition at line 493 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws a line from p1 to p2.
Definition at line 499 of file qpainter.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws a line from (x1, y1) to (x2, y2).
Definition at line 487 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the first lineCount lines in the array lines using the current pen.
Definition at line 4340 of file qpainter.cpp.
Draws the first lineCount lines in the array lines using the current pen.
Definition at line 4291 of file qpainter.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the set of lines defined by the list lines using the current pen and brush.
Definition at line 509 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the set of lines defined by the list lines using the current pen and brush.
Definition at line 504 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws a line for each pair of points in the vector pointPairs using the current pen.
Definition at line 519 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws a line for each pair of points in the vector pointPairs using the current pen. If there is an odd number of points in the array, the last point will be ignored.
Definition at line 514 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the first lineCount lines in the array pointPairs using the current pen.
Definition at line 4403 of file qpainter.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the first 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.
Definition at line 4390 of file qpainter.cpp.
void QPainter::drawPath | ( | const QPainterPath & | path | ) |
Draws the given painter path using the current pen for outline and the current brush for filling.
\table 100% \row
Definition at line 3171 of file qpainter.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Replays the given picture at the given point.
Definition at line 909 of file qpainter.h.
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-independent format. Everything that can be painted on a widget or pixmap can also be stored in a picture.
This function does exactly the same as QPicture::play() when called with point = QPointF(0, 0).
\table 100% \row
Definition at line 6532 of file qpainter.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the given picture at point (x, y).
Definition at line 904 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws a pie defined by the given rectangle, startAngle and and spanAngle.
Definition at line 643 of file qpainter.h.
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 full circle 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.
\table 100% \row
Definition at line 4175 of file qpainter.cpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the given pixmap with its origin at the given point.
Definition at line 758 of file qpainter.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the rectangular portion source of the given pixmap with its origin at the given point.
Definition at line 795 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the given pixmap with its origin at the given point.
Definition at line 4811 of file qpainter.cpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the rectangular portion source of the given pixmap with its origin at the given point.
Definition at line 790 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the given pixmap into the given rectangle.
Definition at line 763 of file qpainter.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the rectangular portion source of the given pixmap into the given target in the paint device.
Definition at line 753 of file qpainter.h.
Draws the rectangular portion source of the given pixmap into the given target in the paint device.
\table 100% \row
If pixmap is a QBitmap it is drawn with the bits that are "set" using the pens color. If backgroundMode is Qt::OpaqueMode, the "unset" bits are drawn 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.
Definition at line 4883 of file qpainter.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the given pixmap at position ({x}, {y}).
Definition at line 768 of file qpainter.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws a pixmap at ({x}, {y}) by copying a part of the given pixmap into the paint device.
({x}, {y}) specifies the top-left point in the paint device that is to be drawn onto. ({sx}, {sy}) specifies the top-left point in pixmap that is to be drawn. The default is (0, 0).
({sw}, {sh}) specifies the size of the pixmap that is to be drawn. The default, (0, 0) (and negative) means all the way to the bottom-right of the pixmap.
Definition at line 784 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the pixmap into the rectangle at position ({x}, {y}) with the given width and height.
Definition at line 773 of file qpainter.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the rectangular portion with the origin ({sx}, {sy}), width sw and height sh, of the given pixmap , at the point ({x}, {y}), with a width of w and a height of h. If sw or sh are equal to zero the width/height of the pixmap is used and adjusted by the offset sx/sy;
Definition at line 778 of file qpainter.h.
void QPainter::drawPixmapFragments | ( | const PixmapFragment * | fragments, |
int | fragmentCount, | ||
const QPixmap & | pixmap, | ||
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 state changes.
Definition at line 8009 of file qpainter.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws a single point at the given position using the current pen's color.
Definition at line 591 of file qpainter.h.
Draws a single point at the given position using the current pen's color.
Definition at line 580 of file qpainter.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws a single point at position (x, y).
Definition at line 585 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the first pointCount points in the array points using the current pen's color.
Definition at line 3509 of file qpainter.cpp.
Draws the first pointCount points in the array points using the current pen's color.
Definition at line 3447 of file qpainter.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the points in the vector points.
Definition at line 601 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the points in the vector points.
Definition at line 596 of file qpainter.h.
void QPainter::drawPolygon | ( | const QPoint * | points, |
int | pointCount, | ||
Qt::FillRule | fillRule = Qt::OddEvenFill |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the polygon defined by the first pointCount points in the array points.
Definition at line 4614 of file qpainter.cpp.
void QPainter::drawPolygon | ( | const QPointF * | points, |
int | pointCount, | ||
Qt::FillRule | fillRule = Qt::OddEvenFill |
||
) |
Draws the polygon defined by the first pointCount points in the array points using the current pen and brush.
\table 100% \row
The first point is implicitly connected to the last point, 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-even fill algorithm. See \l{Qt::FillRule} for a more detailed description of these fill rules.
Definition at line 4575 of file qpainter.cpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the polygon defined by the given points using the fill rule fillRule.
Definition at line 539 of file qpainter.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the polygon defined by the given points using the fill rule fillRule.
Definition at line 534 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the polyline defined by the first pointCount points in points using the current pen.
Definition at line 4500 of file qpainter.cpp.
Draws the polyline defined by the first pointCount points in points using the current pen.
Note that unlike the drawPolygon() function the last point is not connected to the first, neither is the polyline filled.
\table 100% \row
Definition at line 4459 of file qpainter.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the polyline defined by the given points using the current pen.
Definition at line 529 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the polyline defined by the given points using the current pen.
Definition at line 524 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the current rectangle with the current pen and brush.
Definition at line 565 of file qpainter.h.
Draws the current rectangle with the current pen and brush.
A filled rectangle has a size of {rectangle}.size(). A stroked rectangle has a size of {rectangle}.size() plus the pen width.
\table 100% \row
Definition at line 554 of file qpainter.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws a rectangle with upper left corner at ({x}, {y}) and with the given width and height.
Definition at line 559 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the given rectangles using the current pen and brush.
Definition at line 575 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the given rectangles using the current pen and brush.
Definition at line 570 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the first rectCount of the given rectangles using the current pen and brush.
Definition at line 3347 of file qpainter.cpp.
Draws the first rectCount of the given rectangles using the current pen and brush.
Definition at line 3287 of file qpainter.cpp.
|
inline |
Draws the given rectangle rect with rounded corners.
Definition at line 612 of file qpainter.h.
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 mode is Qt::RelativeSize, xRadius and yRadius are specified in percentage 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.
\table 100% \row
Definition at line 3924 of file qpainter.cpp.
|
inline |
Draws the given rectangle x, y, w, h with rounded corners.
Definition at line 606 of file qpainter.h.
|
inline |
Draws the staticText at the topLeftPosition.
Definition at line 848 of file qpainter.h.
void QPainter::drawStaticText | ( | const QPointF & | topLeftPosition, |
const QStaticText & | staticText | ||
) |
Draws the given staticText at the given topLeftPosition.
The text will be drawn using the font and the transformation set on the painter. If the font and/or transformation set on 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::prepare() to initialize staticText with the font and transformation with which it will later be drawn.
If topLeftPosition is not the same as when staticText was initialized, or when it was last drawn, then there will be a slight overhead when translating the text to its new position.
Definition at line 5470 of file qpainter.cpp.
|
inline |
Draws the staticText at coordinates left and top.
Definition at line 853 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the given text with the currently defined text direction, beginning at the given position.
By default, QPainter draws text anti-aliased.
Definition at line 863 of file qpainter.h.
Draws the given text with the currently defined text direction, beginning at the given position.
This function does not handle the newline character (\n), as it cannot break text into multiple lines, and it cannot display the newline character. Use 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 want the text to be wrapped.
By default, QPainter draws text anti-aliased.
Definition at line 5444 of file qpainter.cpp.
void QPainter::drawText | ( | const QRect & | rectangle, |
int | flags, | ||
const QString & | text, | ||
QRect * | boundingRect = nullptr |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the given text within the provided rectangle according to the specified flags.
The boundingRect (if not null) is set to the what the bounding rectangle should be in order to enclose the whole text. For example, in the following image, the dotted line represents boundingRect as calculated by the function, and the dashed line represents rectangle:
\table 100% \row
By default, QPainter draws text anti-aliased.
Definition at line 5664 of file qpainter.cpp.
void QPainter::drawText | ( | const QRectF & | rectangle, |
const QString & | text, | ||
const QTextOption & | option = QTextOption() |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
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.
Definition at line 5870 of file qpainter.cpp.
void QPainter::drawText | ( | const QRectF & | rectangle, |
int | flags, | ||
const QString & | text, | ||
QRectF * | boundingRect = nullptr |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the given text within the provided rectangle. The rectangle along with alignment flags defines the anchors for the text.
\table 100% \row
The boundingRect (if not null) is set to what the bounding rectangle should be in order to enclose the whole text. For example, in the following image, the dotted line represents boundingRect as calculated by the function, and the dashed line represents rectangle:
\table 100% \row
The flags argument is a bitwise OR of the following flags:
\list
By default, QPainter draws text anti-aliased.
Definition at line 5751 of file qpainter.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the given text at position ({x}, {y}), using the painter's currently defined text direction.
By default, QPainter draws text anti-aliased.
Definition at line 873 of file qpainter.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the given text within the rectangle with origin ({x}, {y}), width and height.
The boundingRect (if not null) is set to the what the bounding rectangle should be in order to enclose the whole text. For example, in the following image, the dotted line represents boundingRect as calculated by the function, and the dashed line represents the rectangle defined by x, y, width and height:
\table 100% \row
The flags argument is a bitwise OR of the following flags:
\list
By default, QPainter draws text anti-aliased.
Definition at line 868 of file qpainter.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws a tiled pixmap, inside the given rectangle with its origin at the given position.
Definition at line 743 of file qpainter.h.
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 area with a pixmap, but is potentially much more efficient depending on the underlying window system.
drawTiledPixmap() will produce the same visual tiling pattern on high-dpi displays (with devicePixelRatio > 1), compared to normal- dpi displays. Set the devicePixelRatio on the pixmap to control the tile size. For example, setting it to 2 halves the tile width and height (on both 1x and 2x displays), and produces high-resolution output on 2x displays.
The position offset is always in the painter coordinate system, indepentent of display devicePixelRatio.
Definition at line 6402 of file qpainter.cpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws a tiled pixmap in the specified rectangle.
({x}, {y}) specifies the top-left point in the paint device that is to be drawn onto; with the given width and height. ({sx}, {sy}) specifies the top-left point in the pixmap that is to be drawn; this defaults to (0, 0).
Definition at line 748 of file qpainter.h.
bool QPainter::end | ( | ) |
Ends painting. Any resources used while painting are released. You don't normally need to call this since it is called by the destructor.
Returns true
if the painter is no longer active; otherwise returns false
.
Definition at line 1877 of file qpainter.cpp.
void QPainter::endNativePainting | ( | ) |
Restores the painter after manually issuing native painting commands. Lets the painter restore any native state that it relies on before calling any other painter commands.
Definition at line 1988 of file qpainter.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Erases the area inside the given rectangle.
Definition at line 668 of file qpainter.h.
Erases the area inside the given rectangle. Equivalent to calling
Definition at line 6573 of file qpainter.cpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Erases the area inside the rectangle beginning at (x, y) with the given width and height.
Definition at line 673 of file qpainter.h.
void QPainter::fillPath | ( | const QPainterPath & | path, |
const QBrush & | brush | ||
) |
Fills the given path using the given brush. The outline is not drawn.
Alternatively, you can specify a QColor instead of a QBrush; the QBrush constructor (taking a QColor argument) will automatically create a solid pattern brush.
Definition at line 3127 of file qpainter.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Fills the given rectangle with the specified brush.
Definition at line 6679 of file qpainter.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Fills the given rectangle with the color specified.
Definition at line 6717 of file qpainter.cpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Fills the given rectangle with the specified gradient preset.
Definition at line 723 of file qpainter.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Fills the given rectangle with the brush style specified.
Definition at line 708 of file qpainter.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Fills the given rectangle with the specified color.
Definition at line 693 of file qpainter.h.
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) will automatically create a solid pattern brush.
Definition at line 6644 of file qpainter.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Fills the given rectangle with the color specified.
Definition at line 6741 of file qpainter.cpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Fills the given rectangle with the specified gradient preset.
Definition at line 728 of file qpainter.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Fills the given rectangle with the brush style specified.
Definition at line 713 of file qpainter.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Fills the given rectangle with the specified color.
Definition at line 698 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Fills the rectangle beginning at ({x}, {y}) with the given width and height, using the given brush.
Definition at line 678 of file qpainter.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Fills the rectangle beginning at ({x}, {y}) with the given width and height, using the given color.
Definition at line 683 of file qpainter.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Fills the rectangle beginning at ({x}, {y}) with the given width and height, using the given gradient preset.
Definition at line 718 of file qpainter.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Fills the rectangle beginning at ({x}, {y}) with the given width and height, using the brush style specified.
Definition at line 703 of file qpainter.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Fills the rectangle beginning at ({x}, {y}) with the given width and height, using the given color.
Definition at line 688 of file qpainter.h.
Returns the currently set font used for drawing text.
Definition at line 3890 of file qpainter.cpp.
QFontInfo QPainter::fontInfo | ( | ) | const |
Returns the font info for the painter if the painter is active. Otherwise, the return value is undefined.
Definition at line 2027 of file qpainter.cpp.
QFontMetrics QPainter::fontMetrics | ( | ) | const |
Returns the font metrics for the painter if the painter is active. Otherwise, the return value is undefined.
Definition at line 2009 of file qpainter.cpp.
bool QPainter::hasClipping | ( | ) | const |
Returns true
if clipping has been set; otherwise returns false
.
Definition at line 2430 of file qpainter.cpp.
bool QPainter::isActive | ( | ) | const |
Returns true
if begin() has been called and end() has not yet been called; otherwise returns false
.
Definition at line 1544 of file qpainter.cpp.
Qt::LayoutDirection QPainter::layoutDirection | ( | ) | const |
Returns the layout direction used by the painter when drawing text.
Definition at line 7367 of file qpainter.cpp.
qreal QPainter::opacity | ( | ) | const |
Returns the opacity of the painter. The default value is 1.
Definition at line 2044 of file qpainter.cpp.
QPaintEngine * QPainter::paintEngine | ( | ) | const |
Returns the paint engine that the painter is currently operating on if the painter is active; otherwise 0.
Definition at line 1929 of file qpainter.cpp.
Returns the painter's current pen.
Definition at line 3736 of file qpainter.cpp.
QPainter::RenderHints QPainter::renderHints | ( | ) | const |
Returns a flag that specifies the rendering hints that are set for this painter.
Definition at line 6897 of file qpainter.cpp.
void QPainter::resetTransform | ( | ) |
Resets any transformations that were made using translate(), scale(), shear(), rotate(), setWorldTransform(), setViewport() and setWindow().
Definition at line 7913 of file qpainter.cpp.
void QPainter::restore | ( | ) |
Restores the current painter state (pops a saved state off the stack).
Definition at line 1611 of file qpainter.cpp.
Rotates the coordinate system clockwise. The given angle parameter is in degrees.
Definition at line 2970 of file qpainter.cpp.
void QPainter::save | ( | ) |
Scales the coordinate system by ({sx}, {sy}).
Definition at line 2922 of file qpainter.cpp.
Sets the background brush of the painter to the given brush.
The background brush is the brush that is filled in when drawing opaque text, stippled lines and bitmaps. The background brush has no effect in transparent background mode (which is the default).
Definition at line 3836 of file qpainter.cpp.
void QPainter::setBackgroundMode | ( | Qt::BGMode | mode | ) |
Sets the background mode 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 draw a bitmap or pixmap transparently, you must use QPixmap::setMask().
Definition at line 3594 of file qpainter.cpp.
Sets the painter's brush to the given brush.
The painter's brush defines how shapes are filled.
Definition at line 3755 of file qpainter.cpp.
void QPainter::setBrush | ( | Qt::BrushStyle | style | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Sets the painter's brush to black color and the specified style.
Definition at line 3789 of file qpainter.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Sets the brush's origin to the given position.
Definition at line 738 of file qpainter.h.
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 adopt the parent's background for a widget in Qt 3, this is no longer the case since the Qt 4 painter doesn't paint the background unless you explicitly tell it to do so by setting the widget's \l {QWidget::autoFillBackground}{autoFillBackground} property to true.
Definition at line 2122 of file qpainter.cpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Sets the brush's origin to point (x, y).
Definition at line 733 of file qpainter.h.
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 clip path is specified in logical (painter) coordinates.
Definition at line 3038 of file qpainter.cpp.
void QPainter::setClipping | ( | bool | enable | ) |
Enables clipping if enable is true, or disables clipping if enable is false.
Definition at line 2448 of file qpainter.cpp.
void QPainter::setClipRect | ( | const QRect & | rectangle, |
Qt::ClipOperation | operation = Qt::ReplaceClip |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Enables clipping, and sets the clip region to the given rectangle using the given clip operation.
Definition at line 2772 of file qpainter.cpp.
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 replace the current clip rectangle.
Note that the clip rectangle is specified in logical (painter) coordinates.
Definition at line 2717 of file qpainter.cpp.
|
inline |
Enables clipping, and sets the clip region to the rectangle beginning at (x, y) with the given width and height.
Definition at line 663 of file qpainter.h.
void QPainter::setClipRegion | ( | const QRegion & | region, |
Qt::ClipOperation | operation = Qt::ReplaceClip |
||
) |
Sets the clip region to the given region using the specified clip operation. The default clip operation is to replace the current clip region.
Note that the clip region is given in logical coordinates.
Definition at line 2826 of file qpainter.cpp.
void QPainter::setCompositionMode | ( | CompositionMode | mode | ) |
Sets the composition mode to the given mode.
Definition at line 2353 of file qpainter.cpp.
Sets the painter's font to the given font.
This font is used by subsequent drawText() functions. The text color is the same as the pen color.
If you set a font that isn't available, Qt finds a close match. font() will return what you set using setFont() and fontInfo() returns the font actually being used (which may be the same).
Definition at line 3866 of file qpainter.cpp.
void QPainter::setLayoutDirection | ( | Qt::LayoutDirection | direction | ) |
Sets the layout direction used by the painter when drawing text, to the specified direction.
The default is Qt::LayoutDirectionAuto, which will implicitly determine the direction from the text drawn.
Definition at line 7355 of file qpainter.cpp.
Sets the opacity of the painter to opacity. The value should be in the range 0.0 to 1.0, where 0.0 is fully transparent and 1.0 is fully opaque.
Opacity set on the painter will apply to all drawing operations individually.
Definition at line 2065 of file qpainter.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Sets the painter's pen to have style Qt::SolidLine, width 1 and the specified color.
Definition at line 3640 of file qpainter.cpp.
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.
Definition at line 3673 of file qpainter.cpp.
void QPainter::setPen | ( | Qt::PenStyle | style | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Sets the painter's pen to have the given style, width 1 and black color.
Definition at line 3708 of file qpainter.cpp.
void QPainter::setRenderHint | ( | RenderHint | hint, |
bool | on = true |
||
) |
Sets the given render hint on the painter if on is true; otherwise clears the render hint.
Definition at line 6845 of file qpainter.cpp.
Sets the given render hints on the painter if on is true; otherwise clears the render hints.
Definition at line 6871 of file qpainter.cpp.
void QPainter::setTransform | ( | const QTransform & | transform, |
bool | combine = false |
||
) |
Sets the world transformation matrix. If combine is true, the specified transform is combined with the current matrix; otherwise it replaces the current matrix.
Definition at line 7861 of file qpainter.cpp.
Sets the painter's viewport rectangle to the given rectangle, and enables view transformations.
The viewport rectangle is part of the view transformation. The viewport specifies the device coordinate system. Its sister, the window(), specifies the logical coordinate system.
The default viewport rectangle is the same as the device's rectangle.
Definition at line 7022 of file qpainter.cpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Sets the painter's viewport rectangle to be the rectangle beginning at (x, y) with the given width and height.
Definition at line 893 of file qpainter.h.
void QPainter::setViewTransformEnabled | ( | bool | enable | ) |
Enables view transformations if enable is true, or disables view transformations if enable is false.
Definition at line 7069 of file qpainter.cpp.
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 system.
The default window rectangle is the same as the device's rectangle.
Definition at line 6958 of file qpainter.cpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Sets the painter's window to the rectangle beginning at (x, y) and the given width and height.
Definition at line 898 of file qpainter.h.
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.
Definition at line 2878 of file qpainter.cpp.
void QPainter::setWorldTransform | ( | const QTransform & | matrix, |
bool | combine = false |
||
) |
Sets the world transformation matrix. If combine is true, the specified matrix is combined with the current matrix; otherwise it replaces the current matrix.
Definition at line 7945 of file qpainter.cpp.
Shears the coordinate system by ({sh}, {sv}).
Definition at line 2945 of file qpainter.cpp.
void QPainter::strokePath | ( | const QPainterPath & | path, |
const QPen & | pen | ||
) |
Draws the outline (strokes) the path path with the pen specified by pen
Definition at line 3087 of file qpainter.cpp.
|
inline |
Returns true
if hint is set; otherwise returns false
.
Definition at line 442 of file qpainter.h.
const QTransform & QPainter::transform | ( | ) | const |
Alias for worldTransform(). Returns the world transformation matrix.
Definition at line 7873 of file qpainter.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Translates the coordinate system by the given offset.
Definition at line 888 of file qpainter.h.
Translates the coordinate system by the given offset; i.e. the given offset is added to points.
Definition at line 2993 of file qpainter.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Translates the coordinate system by the vector (dx, dy).
Definition at line 883 of file qpainter.h.
QRect QPainter::viewport | ( | ) | const |
Returns the viewport rectangle.
Definition at line 7051 of file qpainter.cpp.
bool QPainter::viewTransformEnabled | ( | ) | const |
Returns true
if view transformation is enabled; otherwise returns false.
Definition at line 6923 of file qpainter.cpp.
QRect QPainter::window | ( | ) | const |
Returns the window rectangle.
Definition at line 6987 of file qpainter.cpp.
bool QPainter::worldMatrixEnabled | ( | ) | const |
Returns true
if world transformation is enabled; otherwise returns false.
Definition at line 2906 of file qpainter.cpp.
const QTransform & QPainter::worldTransform | ( | ) | const |
Returns the world transformation matrix.
Definition at line 7967 of file qpainter.cpp.
|
friend |
Definition at line 466 of file qpainter.h.
|
friend |
Definition at line 455 of file qpainter.h.
|
friend |
Definition at line 456 of file qpainter.h.
|
friend |
Definition at line 457 of file qpainter.h.
|
friend |
Definition at line 458 of file qpainter.h.
|
friend |
Definition at line 459 of file qpainter.h.
|
friend |
Definition at line 462 of file qpainter.h.
|
friend |
Definition at line 460 of file qpainter.h.
|
friend |
Definition at line 461 of file qpainter.h.
|
friend |
Definition at line 467 of file qpainter.h.
|
friend |
Definition at line 465 of file qpainter.h.
|
friend |
Definition at line 468 of file qpainter.h.
|
friend |
Definition at line 454 of file qpainter.h.
|
friend |
Definition at line 463 of file qpainter.h.
|
friend |
Definition at line 464 of file qpainter.h.