继承者: QStylePainter
PySide.QtGui.QPainter class performs low-level painting on widgets and other paint devices.
PySide.QtGui.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. PySide.QtGui.QPainter can operate on any object that inherits the PySide.QtGui.QPaintDevice 类。
The common use of PySide.QtGui.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 PySide.QtGui.QPainter object after drawing. For example:
def paintEvent(self, paintEvent):
painter = QPainter(self)
painter.setPen(Qt.blue)
painter.setFont(QFont("Arial", 30))
painter.drawText(rect(), Qt.AlignCenter, "Qt")
The core functionality of PySide.QtGui.QPainter is drawing, but the class also provide several functions that allows you to customize PySide.QtGui.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.
PySide.QtGui.QPainter.isActive() function indicates whether the painter is active. A painter is activated by the PySide.QtGui.QPainter.begin() function and the constructor that takes a PySide.QtGui.QPaintDevice 自变量。 PySide.QtGui.QPainter.end() function, and the destructor, deactivates it.
连同 PySide.QtGui.QPaintDevice and PySide.QtGui.QPaintEngine classes, PySide.QtGui.QPainter form the basis for Qt's paint system. PySide.QtGui.QPainter is the class used to perform drawing operations. PySide.QtGui.QPaintDevice represents a device that can be painted on using a PySide.QtGui.QPainter . PySide.QtGui.QPaintEngine 提供用于在不同类型设备上描绘的描绘器接口。若描绘器活动, PySide.QtGui.QPainter.device() returns the paint device on which the painter paints, and PySide.QtGui.QPainter.paintEngine() returns the paint engine that the painter is currently operating on. For more information, see the 描绘系统 .
有时,可能期望其它人去描绘在不寻常 PySide.QtGui.QPaintDevice . PySide.QtGui.QPainter supports a static function to do this, PySide.QtGui.QPainter.setRedirected() .
警告
When the paintdevice is a widget, PySide.QtGui.QPainter can only be used inside a paintEvent() function or in a function called by paintEvent(); that is unless the Qt.WA_PaintOutsidePaintEvent widget attribute is set. On Mac OS X and Windows, you can only paint in a paintEvent() function regardless of this attribute's setting.
There are several settings that you can customize to make PySide.QtGui.QPainter draw according to your preferences:
注意:其中一些设置会镜像某些绘制设备设置,如 QWidget.font() 。 QPainter.begin() function (or equivalently the PySide.QtGui.QPainter constructor) copies these attributes from the paint device.
You can at any time save the PySide.QtGui.QPainter ‘s state by calling the PySide.QtGui.QPainter.save() function which saves all the available settings on an internal stack. The PySide.QtGui.QPainter.restore() function pops them back.
PySide.QtGui.QPainter provides functions to draw most primitives: PySide.QtGui.QPainter.drawPoint() , PySide.QtGui.QPainter.drawPoints() , PySide.QtGui.QPainter.drawLine() , PySide.QtGui.QPainter.drawRect() , PySide.QtGui.QPainter.drawRoundedRect() , PySide.QtGui.QPainter.drawEllipse() , PySide.QtGui.QPainter.drawArc() , PySide.QtGui.QPainter.drawPie() , PySide.QtGui.QPainter.drawChord() , PySide.QtGui.QPainter.drawPolyline() , PySide.QtGui.QPainter.drawPolygon() , PySide.QtGui.QPainter.drawConvexPolygon() and drawCubicBezier() . The two convenience functions, PySide.QtGui.QPainter.drawRects() and PySide.QtGui.QPainter.drawLines() , draw the given number of rectangles or lines in the given array of QRects or QLines 使用当前钢笔和笔刷。
PySide.QtGui.QPainter class also provides the PySide.QtGui.QPainter.fillRect() function which fills the given PySide.QtCore.QRect ,采用给定 PySide.QtGui.QBrush ,和 PySide.QtGui.QPainter.eraseRect() function that erases the area inside the given rectangle.
所有这些函数都有整数和浮点版本。
|
基本绘制范例
基本绘制
example shows how to display basic graphics primitives in a variety of styles using the
PySide.QtGui.QPainter
类。
|
If you need to draw a complex shape, especially if you need to do so repeatedly, consider creating a PySide.QtGui.QPainterPath and drawing it using PySide.QtGui.QPainter.drawPath() .
|
描绘器路径范例 PySide.QtGui.QPainterPath class provides a container for painting operations, enabling graphical shapes to be constructed and reused. Painter Paths example shows how painter paths can be used to build complex shapes for rendering. |
|
PySide.QtGui.QPainter also provides the PySide.QtGui.QPainter.fillPath() function which fills the given PySide.QtGui.QPainterPath 采用给定 PySide.QtGui.QBrush ,和 PySide.QtGui.QPainter.strokePath() function that draws the outline of the given path (i.e. strokes the path).
另请参阅 向量变形 demo which shows how to use advanced vector techniques to draw text using a PySide.QtGui.QPainterPath , 渐变 demo which shows the different types of gradients that are available in Qt, and the 路径笔画 demo which shows Qt's built-in dash patterns and shows how custom patterns can be used to extend the range of available patterns.
| 向量变形 | 渐变 | 路径笔画 |
|
|
|
There are functions to draw pixmaps/images, namely PySide.QtGui.QPainter.drawPixmap() , PySide.QtGui.QPainter.drawImage() and PySide.QtGui.QPainter.drawTiledPixmap() . Both PySide.QtGui.QPainter.drawPixmap() and PySide.QtGui.QPainter.drawImage() produce the same result, except that PySide.QtGui.QPainter.drawPixmap() is faster on-screen while PySide.QtGui.QPainter.drawImage() may be faster on a PySide.QtGui.QPrinter or other devices.
Text drawing is done using PySide.QtGui.QPainter.drawText() . When you need fine-grained positioning, PySide.QtGui.QPainter.boundingRect() tells you where a given PySide.QtGui.QPainter.drawText() command will draw.
There is a PySide.QtGui.QPainter.drawPicture() function that draws the contents of an entire PySide.QtGui.QPicture 。 PySide.QtGui.QPainter.drawPicture() function is the only function that disregards all the painter's settings as PySide.QtGui.QPicture has its own settings.
To get the optimal rendering result using PySide.QtGui.QPainter , you should use the platform independent PySide.QtGui.QImage as paint device; i.e. using PySide.QtGui.QImage will ensure that the result has an identical pixel representation on any platform.
PySide.QtGui.QPainter class also provides a means of controlling the rendering quality through its QPainter.RenderHint enum and the support for floating point precision: All the functions for drawing primitives has a floating point version. These are often used in combination with the QPainter.Antialiasing render hint.
|
同心圆范例 Concentric Circles example shows the improved rendering quality that can be obtained using floating point precision and anti-aliasing when drawing custom widgets. The application's main window displays several widgets which are drawn using the various combinations of precision and anti-aliasing. |
QPainter.RenderHint enum specifies flags to PySide.QtGui.QPainter that may or may not be respected by any given engine. QPainter.Antialiasing indicates that the engine should antialias edges of primitives if possible, QPainter.TextAntialiasing indicates that the engine should antialias text if possible, and the QPainter.SmoothPixmapTransform indicates that the engine should use a smooth pixmap transformation algorithm. HighQualityAntialiasing is an OpenGL-specific rendering hint indicating that the engine should use fragment programs and offscreen rendering for antialiasing.
PySide.QtGui.QPainter.renderHints() function returns a flag that specifies the rendering hints that are set for this painter. Use the PySide.QtGui.QPainter.setRenderHint() function to set or clear the currently set RenderHints .
Normally, the PySide.QtGui.QPainter operates on the device's own coordinate system (usually pixels), but PySide.QtGui.QPainter has good support for coordinate transformations.
| nop | PySide.QtGui.QPainter.rotate() | PySide.QtGui.QPainter.scale() | PySide.QtGui.QPainter.translate() |
|
|
|
|
The most commonly used transformations are scaling, rotation, translation and shearing. Use the PySide.QtGui.QPainter.scale() function to scale the coordinate system by a given offset, the PySide.QtGui.QPainter.rotate() function to rotate it clockwise and PySide.QtGui.QPainter.translate() to translate it (i.e. adding a given offset to the points). You can also twist the coordinate system around the origin using the PySide.QtGui.QPainter.shear() function. See the 仿射变换 demo for a visualization of a sheared coordinate system.
另请参阅 变换 example which shows how transformations influence the way that PySide.QtGui.QPainter renders graphics primitives. In particular it shows how the order of transformations affects the result.
|
Affine Transformations Demo
仿射变换
demo show Qt's ability to perform affine transformations on painting operations. The demo also allows the user to experiment with the transformation operations and see the results immediately.
|
|
All the tranformation operations operate on the transformation PySide.QtGui.QPainter.worldTransform() . A matrix transforms a point in the plane to another point. For more information about the transformation matrix, see the 坐标系统 and PySide.QtGui.QTransform 文档编制。
PySide.QtGui.QPainter.setWorldTransform() function can replace or add to the currently set PySide.QtGui.QPainter.worldTransform() 。 PySide.QtGui.QPainter.resetTransform() function resets any transformations that were made using PySide.QtGui.QPainter.translate() , PySide.QtGui.QPainter.scale() , PySide.QtGui.QPainter.shear() , PySide.QtGui.QPainter.rotate() , PySide.QtGui.QPainter.setWorldTransform() , PySide.QtGui.QPainter.setViewport() and PySide.QtGui.QPainter.setWindow() functions. The PySide.QtGui.QPainter.deviceTransform() returns the matrix that transforms from logical coordinates to device coordinates of the platform dependent paint device. The latter function is only needed when using platform painting commands on the platform dependent handle, and the platform does not do transformations nativly.
When drawing with PySide.QtGui.QPainter , we specify points using logical coordinates which then are converted into the physical coordinates of the paint device. The mapping of the logical coordinates to the physical coordinates are handled by PySide.QtGui.QPainter ‘s PySide.QtGui.QPainter.combinedTransform() , a combination of PySide.QtGui.QPainter.viewport() and PySide.QtGui.QPainter.window() and PySide.QtGui.QPainter.worldTransform() 。 PySide.QtGui.QPainter.viewport() represents the physical coordinates specifying an arbitrary rectangle, the PySide.QtGui.QPainter.window() describes the same rectangle in logical coordinates, and the PySide.QtGui.QPainter.worldTransform() is identical with the transformation matrix.
另请参阅 坐标系统
PySide.QtGui.QPainter can clip any drawing operation to a rectangle, a region, or a vector path. The current clip is available using the functions PySide.QtGui.QPainter.clipRegion() and PySide.QtGui.QPainter.clipPath() . Whether paths or regions are preferred (faster) depends on the underlying PySide.QtGui.QPainter.paintEngine() . For example, the PySide.QtGui.QImage paint engine prefers paths while the X11 paint engine prefers regions. Setting a clip is done in the painters logical coordinates.
After PySide.QtGui.QPainter ‘s clipping, the paint device may also clip. For example, most widgets clip away the pixels used by child widgets, and most printers clip away an area near the edges of the paper. This additional clipping is not reflected by the return value of PySide.QtGui.QPainter.clipRegion() or PySide.QtGui.QPainter.hasClipping() .
PySide.QtGui.QPainter provides the QPainter.CompositionMode enum which defines the Porter-Duff rules for digital image compositing; it describes a model for combining the pixels in one image, the source, with the pixels in another image, the destination.
The two most common forms of composition are Source and SourceOver . Source is used to draw opaque objects onto a paint device. In this mode, each pixel in the source replaces the corresponding pixel in the destination. In SourceOver composition mode, the source object is transparent and is drawn on top of the destination.
Note that composition transformation operates pixelwise. For that reason, there is a difference between using the graphic primitive itself and its bounding rectangle: The bounding rect contains pixels with alpha == 0 (i.e the pixels surrounding the primitive). These pixels will overwrite the other image's pixels, affectively clearing those, while the primitive only overwrites its own area.
|
Composition Modes Demo
复合模式
demo, available in Qt's demo directory, allows you to experiment with the various composition modes and see the results immediately.
|
If you are using coordinates with Qt's raster-based paint engine, it is important to note that, while coordinates greater than +/- 2 15 can be used, any painting performed with coordinates outside this range is not guaranteed to be shown; the drawing may be clipped. This is due to the use of short int in the implementation.
The outlines generated by Qt's stroker are only an approximation when dealing with curved shapes. It is in most cases impossible to represent the outline of a bezier curve segment using another bezier curve segment, and so Qt approximates the curve outlines by using several smaller curves. For performance reasons there is a limit to how many curves Qt uses for these outlines, and thus when using large pen widths or scales the outline error increases. To generate outlines with smaller errors it is possible to use the PySide.QtGui.QPainterPathStroker class, which has the setCurveThreshold member function which let's the user specify the error tolerance. Another workaround is to convert the paths to polygons first and then draw the polygons instead.
PySide.QtGui.QPainter is a rich framework that allows developers to do a great variety of graphical operations, such as gradients, composition modes and vector graphics. And PySide.QtGui.QPainter can do this across a variety of different hardware and software stacks. Naturally the underlying combination of hardware and software has some implications for performance, and ensuring that every single operation is fast in combination with all the various combinations of composition modes, brushes, clipping, transformation, etc, is close to an impossible task because of the number of permutations. As a compromise we have selected a subset of the PySide.QtGui.QPainter API and backends, where performance is guaranteed to be as good as we can sensibly get it for the given combination of hardware and software.
The backends we focus on as high-performance engines are:
These operations are:
This list gives an indication of which features to safely use in an application where performance is critical. For certain setups, other operations may be fast too, but before making extensive use of them, it is recommended to benchmark and verify them on the system where the software will run in the end. There are also cases where expensive operations are ok to use, for instance when the result is cached in a PySide.QtGui.QPixmap .
另请参阅
PySide.QtGui.QPaintDevice PySide.QtGui.QPaintEngine QtSvg Module 基本绘制范例 Drawing Utility Functions
| 参数: | arg__1 – PySide.QtGui.QPaintDevice |
|---|
构造描绘器。
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 PySide.QtGui.QPainter.begin() for you and the PySide.QtGui.QPainter destructor automatically calls PySide.QtGui.QPainter.end() .
Here's an example using PySide.QtGui.QPainter.begin() and PySide.QtGui.QPainter.end() :
def paintEvent(self, paintEvent):
p = QPainter()
p.begin(self)
p.drawLine(...) # drawing code
p.end()
The same example using this constructor:
self paintEvent(self, paintEvent):
p = QPainter(self)
p.drawLine(...) # drawing code
Since the constructor cannot provide feedback when the initialization of the painter failed you should rather use PySide.QtGui.QPainter.begin() and PySide.QtGui.QPainter.end() to paint on external devices, e.g. printers.
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 PySide.QtGui.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.
When the paint device is a PySide.QtGui.QImage , the image format must be set to Format_ARGB32Premultiplied or Format_ARGB32 for the composition modes to have any effect. For performance the premultiplied version is the preferred format.
When a composition mode is set it applies to all painting operator, pens, brushes, gradients and pixmap/image drawing.
| 常量 | 描述 |
|---|---|
| QPainter.CompositionMode_SourceOver | This is the default mode. The alpha of the source is used to blend the pixel on top of the destination. |
| QPainter.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 . |
| QPainter.CompositionMode_Clear | The pixels in the destination are cleared (set to fully transparent) independent of the source. |
| QPainter.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). |
| QPainter.CompositionMode_Destination | The output is the destination pixel. This means that the blending has no effect. This mode is the inverse of CompositionMode_Source . |
| QPainter.CompositionMode_SourceIn | The output is the source, where the alpha is reduced by that of the destination. |
| QPainter.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 . |
| QPainter.CompositionMode_SourceOut | The output is the source, where the alpha is reduced by the inverse of destination. |
| QPainter.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 . |
| QPainter.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. |
| QPainter.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 . |
| QPainter.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. |
| QPainter.CompositionMode_Plus | Both the alpha and color of the source and destination pixels are added together. |
| QPainter.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. |
| QPainter.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. |
| QPainter.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. |
| QPainter.CompositionMode_Darken | The darker of the source and destination colors is selected. |
| QPainter.CompositionMode_Lighten | The lighter of the source and destination colors is selected. |
| QPainter.CompositionMode_ColorDodge | The destination color is brightened to reflect the source color. A black source color leaves the destination color unchanged. |
| QPainter.CompositionMode_ColorBurn | The destination color is darkened to reflect the source color. A white source color leaves the destination color unchanged. |
| QPainter.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. |
| QPainter.CompositionMode_SoftLight | Darkens or lightens the colors depending on the source color. Similar to CompositionMode_HardLight . |
| QPainter.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. |
| QPainter.CompositionMode_Exclusion | 类似 CompositionMode_Difference , but with a lower contrast. Painting with white inverts the destination color, whereas painting with black leaves the destination color unchanged. |
| QPainter.RasterOp_SourceOrDestination | Does a bitwise OR operation on the source and destination pixels (src OR dst). |
| QPainter.RasterOp_SourceAndDestination | Does a bitwise AND operation on the source and destination pixels (src AND dst). |
| QPainter.RasterOp_SourceXorDestination | Does a bitwise XOR operation on the source and destination pixels (src XOR dst). |
| QPainter.RasterOp_NotSourceAndNotDestination | Does a bitwise NOR operation on the source and destination pixels ((NOT src) AND (NOT dst)). |
| QPainter.RasterOp_NotSourceOrNotDestination | Does a bitwise NAND operation on the source and destination pixels ((NOT src) OR (NOT dst)). |
| QPainter.RasterOp_NotSourceXorDestination | Does a bitwise operation where the source pixels are inverted and then XOR'ed with the destination ((NOT src) XOR dst). |
| QPainter.RasterOp_NotSource | Does a bitwise operation where the source pixels are inverted (NOT src). |
| QPainter.RasterOp_NotSourceAndDestination | Does a bitwise operation where the source is inverted and then AND'ed with the destination ((NOT src) AND dst). |
| QPainter.RasterOp_SourceAndNotDestination | Does a bitwise operation where the source is AND'ed with the inverted destination pixels (src AND (NOT dst)). |
另请参阅
PySide.QtGui.QPainter.compositionMode() PySide.QtGui.QPainter.setCompositionMode() Composition Modes 图像合成范例
Renderhints are used to specify flags to PySide.QtGui.QPainter that may or may not be respected by any given engine.
| 常量 | 描述 |
|---|---|
| QPainter.Antialiasing | Indicates that the engine should antialias edges of primitives if possible. |
| QPainter.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. |
| QPainter.SmoothPixmapTransform | Indicates that the engine should use a smooth pixmap transformation algorithm (such as bilinear) rather than nearest neighbor. |
| QPainter.HighQualityAntialiasing | An OpenGL-specific rendering hint indicating that the engine should use fragment programs and offscreen rendering for antialiasing. |
| QPainter.NonCosmeticDefaultPen | The engine should interpret pens with a width of 0 (which otherwise enables QPen.isCosmetic() ) as being a non-cosmetic pen with a width of 1. |
另请参阅
PySide.QtGui.QPainter.renderHints() PySide.QtGui.QPainter.setRenderHint() 渲染 Quality 同心圆范例
| 常量 | 描述 |
|---|---|
| QPainter.OpaqueHint | Indicates that the pixmap fragments to be drawn are opaque. Opaque fragments are potentially faster to draw. |
另请参阅
QPainter.drawPixmapFragments() QPainter.PixmapFragment
注意
This enum was introduced or modified in Qt 4.7
| 返回类型: | PySide.QtGui.QBrush |
|---|
返回当前背景笔刷。
| 返回类型: | PySide.QtCore.Qt.BGMode |
|---|
返回当前背景模式。
| 参数: | arg__1 – PySide.QtGui.QPaintDevice |
|---|---|
| 返回类型: | PySide.QtCore.bool |
Begins painting the paint device and returns true if successful; otherwise returns false.
Notice that all painter settings ( PySide.QtGui.QPainter.setPen() , PySide.QtGui.QPainter.setBrush() etc.) are reset to default values when PySide.QtGui.QPainter.begin() 被调用。
The errors that can occur are serious problems, such as these:
painter.begin(0) # impossible - paint device cannot be 0
image = QPixmap(0, 0)
painter.begin(&image) # impossible - image.isNull() == true
painter.begin(myWidget)
painter2.begin(myWidget) # impossible - only one painter at a time
Note that most of the time, you can use one of the constructors instead of PySide.QtGui.QPainter.begin() , and that PySide.QtGui.QPainter.end() is automatically done at destruction.
警告
A paint device can only be painted by one painter at a time.
警告
Painting on a PySide.QtGui.QImage with the format QImage.Format_Indexed8 不被支持。
另请参阅
PySide.QtGui.QPainter.end() PySide.QtGui.QPainter.QPainter()
Flushes the painting pipeline and prepares for the user issuing commands directly to the underlying graphics context. Must be followed by a call to PySide.QtGui.QPainter.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:
If, for example, the OpenGL polygon mode is changed by the user inside a beginNativePaint()/ PySide.QtGui.QPainter.endNativePainting() block, it will not be reset to the default state by PySide.QtGui.QPainter.endNativePainting() . Here is an example that shows intermixing of painter commands and raw OpenGL commands:
painter = QPainter(self)
painter.fillRect(0, 0, 128, 128, Qt.green)
painter.beginNativePainting()
glEnable(GL_SCISSOR_TEST)
glScissor(0, 0, 64, 64)
glClearColor(1, 0, 0, 1)
glClear(GL_COLOR_BUFFER_BIT)
glDisable(GL_SCISSOR_TEST)
painter.endNativePainting()
| 参数: |
|
|---|---|
| 返回类型: |
这是重载函数。
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 .
| 参数: |
|
|---|---|
| 返回类型: |
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 PySide.QtGui.QPainter.font() ; i.e the function tells you where the PySide.QtGui.QPainter.drawText() function will draw when given the same arguments.
若 text does not fit within the given rectangle 使用指定 flags , the function returns the required rectangle.
flags argument is a bitwise OR of the following flags:
If several of the horizontal or several of the vertical alignment flags are set, the resulting alignment is undefined.
另请参阅
PySide.QtGui.QPainter.drawText() Qt.Alignment Qt.TextFlag
| 参数: |
|
|---|---|
| 返回类型: |
这是重载函数。
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 PySide.QtGui.QPainter.font() .
| 参数: |
|
|---|---|
| 返回类型: |
这是重载函数。
Instead of specifying flags as a bitwise OR of the Qt.AlignmentFlag and Qt.TextFlag , this overloaded function takes an option 自变量。 PySide.QtGui.QTextOption class provides a description of general rich text properties.
| 返回类型: | PySide.QtGui.QBrush |
|---|
Returns the painter's current brush.
另请参阅
| 返回类型: | PySide.QtCore.QPoint |
|---|
Returns the currently set brush origin.
| 返回类型: | PySide.QtCore.QRectF |
|---|
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.
| 返回类型: | PySide.QtGui.QPainterPath |
|---|
Returns the currently clip as a path. Note that the clip path is given in logical coordinates.
警告
PySide.QtGui.QPainter does not store the combined clip explicitly as this is handled by the underlying PySide.QtGui.QPaintEngine , so the path is recreated on demand and transformed to the current logical coordinate system. This is potentially an expensive operation.
| 返回类型: | PySide.QtGui.QRegion |
|---|
Returns the currently set clip region. Note that the clip region is given in logical coordinates.
警告
PySide.QtGui.QPainter does not store the combined clip explicitly as this is handled by the underlying PySide.QtGui.QPaintEngine , so the path is recreated on demand and transformed to the current logical coordinate system. This is potentially an expensive operation.
| 返回类型: | PySide.QtGui.QMatrix |
|---|
Returns the transformation matrix combining the current window/viewport and world transformation.
It is advisable to use PySide.QtGui.QPainter.combinedTransform() instead of this function to preserve the properties of perspective transformations.
| 返回类型: | PySide.QtGui.QTransform |
|---|
Returns the transformation matrix combining the current window/viewport and world transformation.
| 返回类型: | PySide.QtGui.QPainter.CompositionMode |
|---|
Returns the current composition mode.
另请参阅
QPainter.CompositionMode PySide.QtGui.QPainter.setCompositionMode()
| 返回类型: | PySide.QtGui.QPaintDevice |
|---|
Returns the paint device on which this painter is currently painting, or 0 if the painter is not active.
| 返回类型: | PySide.QtGui.QMatrix |
|---|
Returns the matrix that transforms from logical coordinates to device coordinates of the platform dependent paint device.
注意
It is advisable to use PySide.QtGui.QPainter.deviceTransform() instead of this function to preserve the properties of perspective transformations.
此函数是 only needed when using platform painting commands on the platform dependent handle ( Qt.HANDLE ), and the platform does not do transformations nativly.
QPaintEngine.PaintEngineFeature enum can be queried to determine whether the platform performs the transformations or not.
| 返回类型: | PySide.QtGui.QTransform |
|---|
Returns the matrix that transforms from logical coordinates to device coordinates of the platform dependent paint device.
此函数是 only needed when using platform painting commands on the platform dependent handle ( Qt.HANDLE ), and the platform does not do transformations nativly.
QPaintEngine.PaintEngineFeature enum can be queried to determine whether the platform performs the transformations or not.
| 参数: |
|
|---|
这是重载函数。
Draws the arc defined by the rectangle beginning at ( x , y ) with the specified width and height ,和给定 startAngle and spanAngle .
| 参数: |
|
|---|
Draws the arc defined by the given rectangle , startAngle and spanAngle .
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.
|
rectangle = QRectF(10.0, 20.0, 80.0, 60.0)
startAngle = 30 * 16
spanAngle = 120 * 16
painter = QPainter(self)
painter.drawArc(rectangle, startAngle, spanAngle)
|
| 参数: |
|
|---|
这是重载函数。
Draws the arc defined by the given rectangle , startAngle and spanAngle .
| 参数: |
|
|---|
Draws the chord defined by the given rectangle , startAngle and spanAngle . The chord is filled with the current PySide.QtGui.QPainter.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.
|
rectangle = QRectF(10.0, 20.0, 80.0, 60.0)
startAngle = 30 * 16
spanAngle = 120 * 16
painter = QPainter(self)
painter.drawChord(rect, startAngle, spanAngle)
|
| 参数: |
|
|---|
这是重载函数。
Draws the chord defined by the rectangle beginning at ( x , y ) with the specified width and height ,和给定 startAngle and spanAngle .
| 参数: |
|
|---|
这是重载函数。
Draws the chord defined by the given rectangle , startAngle and spanAngle .
| 参数: | polygon – PySide.QtGui.QPolygon |
|---|
这是重载函数。
Draws the convex polygon defined by polygon 使用当前钢笔和笔刷。
| 参数: | polygon – PySide.QtGui.QPolygonF |
|---|
这是重载函数。
Draws the convex polygon defined by polygon 使用当前钢笔和笔刷。
| 参数: | arg__1 – |
|---|
| 参数: | arg__1 – |
|---|
| 参数: | r – PySide.QtCore.QRectF |
|---|
Draws the ellipse defined by the given rectangle .
A filled ellipse has a size of rectangle . PySide.QtCore.QRect.size() . A stroked ellipse has a size of rectangle . PySide.QtCore.QRect.size() plus the pen width.
|
rectangle = QRectF(10.0, 20.0, 80.0, 60.0)
painter = QPainter(self)
painter.drawEllipse(rectangle)
|
另请参阅
| 参数: | r – PySide.QtCore.QRect |
|---|
这是重载函数。
Draws the ellipse defined by the given rectangle .
| 参数: |
|
|---|
这是重载函数。
Draws the ellipse defined by the rectangle beginning at ( x , y ) with the given width and height .
| 参数: |
|
|---|
这是重载函数。
Draws the ellipse positioned at center with radii rx and ry .
| 参数: |
|
|---|
这是重载函数。
Draws the ellipse positioned at center with radii rx and ry .
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
这是重载函数。
绘制给定 image 进给定 rectangle .
注意
The image is scaled to fit the rectangle, if both the image and rectangle size disagree.
| 参数: |
|
|---|
这是重载函数。
绘制给定 image 进给定 rectangle .
注意
The image is scaled to fit the rectangle, if both the image and rectangle size disagree.
| 参数: |
|
|---|
这是重载函数。
绘制给定 image at the given point .
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
这是重载函数。
绘制给定 image at the given point .
| 参数: |
|
|---|
这是重载函数。
Draws a line from p1 to p2 .
| 参数: |
|
|---|
这是重载函数。
Draws a line from p1 to p2 .
| 参数: |
|
|---|
这是重载函数。
Draws a line from ( x1 , y1 ) to ( x2 , y2 ) and sets the current pen position to ( x2 , y2 ).
| 参数: | line – PySide.QtCore.QLineF |
|---|
Draws a line defined by line .
|
line = QLineF(10.0, 80.0, 90.0, 20.0)
painter = QPainter(self)
painter.drawLine(line)
|
| 参数: | line – PySide.QtCore.QLine |
|---|
这是重载函数。
Draws a line defined by line .
| 参数: | lines – |
|---|
| 参数: | pointPairs – |
|---|
| 参数: | pointPairs – |
|---|
| 参数: | lines – |
|---|
| 参数: | path – PySide.QtGui.QPainterPath |
|---|
Draws the given painter path using the current pen for outline and the current brush for filling.
|
path = QPainterPath()
path.moveTo(20, 80)
path.lineTo(20, 30)
path.cubicTo(80, 0, 50, 50, 80, 80)
painter = QPainter(self)
painter.drawPath(path)
|
另请参阅
the Painter Paths example the Vector Deformation demo
| 参数: |
|
|---|
这是重载函数。
绘制给定 picture at point ( x , y ).
| 参数: |
|
|---|
Replays the given picture at the given point .
PySide.QtGui.QPicture 类是描绘设备,它记录并重演 PySide.QtGui.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 = PySide.QtCore.QPoint (0, 0).
picture = QPicture()
point = QPointF(10.0, 20.0)
picture.load("drawing.pic")
painter = QPainter(self)
painter.drawPicture(0, 0, picture)
|
另请参阅
| 参数: |
|
|---|
这是重载函数。
Replays the given picture at the given point .
| 参数: |
|
|---|
这是重载函数。
Draws the pie defined by the rectangle beginning at ( x , y ) with the specified width and height ,和给定 startAngle and spanAngle .
| 参数: |
|
|---|
Draws a pie defined by the given rectangle , startAngle and and spanAngle .
The pie is filled with the current PySide.QtGui.QPainter.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.
|
rectangle = QRectF(10.0, 20.0, 80.0, 60.0)
startAngle = 30 * 16
spanAngle = 120 * 16
painter = QPainter(self)
painter.drawPie(rectangle, startAngle, spanAngle)
|
| 参数: |
|
|---|
这是重载函数。
Draws a pie defined by the given rectangle , startAngle and and spanAngle .
| 参数: |
|
|---|
这是重载函数。
绘制给定 pixmap at position ( x , y ).
| 参数: |
|
|---|
Draws the rectangular portion source 为给定 pixmap 进给定 target in the paint device.
注意
The pixmap is scaled to fit the rectangle, if both the pixmap and rectangle size disagree.
target = QRectF(10.0, 20.0, 80.0, 60.0)
source = QRectF(0.0, 0.0, 70.0, 40.0)
pixmap = QPixmap(":myPixmap.png")
painter = QPainter(self)
painter.drawPixmap(target, image, source)
|
若 pixmap 是 PySide.QtGui.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.
| 参数: |
|
|---|
这是重载函数。
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.
| 参数: |
|
|---|
这是重载函数。
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;
| 参数: |
|
|---|
这是重载函数。
Draws the pixmap into the rectangle at position ( x , y ) with the given width and height .
| 参数: |
|
|---|
这是重载函数。
Draws the rectangular portion source 为给定 pixmap with its origin at the given point .
| 参数: |
|
|---|
这是重载函数。
Draws the rectangular portion source 为给定 pixmap 进给定 target in the paint device.
注意
The pixmap is scaled to fit the rectangle, if both the pixmap and rectangle size disagree.
| 参数: |
|
|---|
这是重载函数。
Draws the rectangular portion source 为给定 pixmap with its origin at the given point .
| 参数: |
|
|---|
这是重载函数。
绘制给定 pixmap with its origin at the given point .
| 参数: |
|---|
这是重载函数。
绘制给定 pixmap with its origin at the given point .
| 参数: |
|
|---|
这是重载函数。
绘制给定 pixmap 进给定 rectangle .
注意
The pixmap is scaled to fit the rectangle, if both the pixmap and rectangle size disagree.
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: | pt – PySide.QtCore.QPointF |
|---|
Draws a single point at the given position using the current pen's color.
另请参阅
坐标系统
| 参数: |
|
|---|
这是重载函数。
Draws a single point at position ( x , y ).
| 参数: | p – PySide.QtCore.QPoint |
|---|
这是重载函数。
Draws a single point at the given position using the current pen's color.
| 参数: | points – PySide.QtGui.QPolygonF |
|---|
这是重载函数。
Draws the points in the vector points .
| 参数: | points – PySide.QtGui.QPolygon |
|---|
这是重载函数。
Draws the points in the vector points .
| 参数: | arg__1 – |
|---|
| 参数: | arg__1 – |
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: | polyline – PySide.QtGui.QPolygonF |
|---|
这是重载函数。
Draws the polyline defined by the given points using the current pen.
| 参数: | polygon – PySide.QtGui.QPolygon |
|---|
这是重载函数。
Draws the polyline defined by the given points using the current pen.
| 参数: | arg__1 – |
|---|
| 参数: | arg__1 – |
|---|
| 参数: |
|
|---|
这是重载函数。
Draws a rectangle with upper left corner at ( x , y ) and with the given width and height .
| 参数: | rect – PySide.QtCore.QRectF |
|---|
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.
|
rectangle = QRectF(10.0, 20.0, 80.0, 60.0)
painter = QPainter(self)
painter.drawRect(rectangle)
|
| 参数: | rect – PySide.QtCore.QRect |
|---|
这是重载函数。
Draws the current rectangle with the current pen and brush.
| 参数: | rectangles – |
|---|
| 参数: | rectangles – |
|---|
| 参数: |
|
|---|
这是重载函数。
Draws the rectangle x , y , w , h with rounded corners.
| 参数: |
|
|---|
Draws a rectangle r with rounded corners.
xRnd and yRnd arguments specify how rounded the corners should be. 0 is angled corners, 99 is maximum roundedness.
A filled rectangle has a size of r. size() . A stroked rectangle has a size of r. size() plus the pen width.
| 参数: |
|
|---|
这是重载函数。
Draws the rectangle r with rounded corners.
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
这是重载函数。
绘制给定 text within the provided rectangle .
|
painter = QPainter(self)
painter.drawText(rect, Qt.AlignCenter, tr("Qt by\nTrolltech"))
|
boundingRect (if not null) is set to the what the bounding rectangle should be in order to enclose the whole text. The flags argument is a bitwise OR of the following flags:
默认情况下, PySide.QtGui.QPainter 绘制抗锯齿文本。
注意
The y-coordinate of rectangle is used as the top of the font.
另请参阅
Qt.AlignmentFlag Qt.TextFlag PySide.QtGui.QPainter.boundingRect() PySide.QtGui.QPainter.layoutDirection()
| 参数: |
|
|---|
这是重载函数。
绘制给定 text at position ( x , y ), using the painter's currently defined text direction.
默认情况下, PySide.QtGui.QPainter 绘制抗锯齿文本。
注意
The y-position is used as the baseline of the font.
| 参数: |
|
|---|
这是重载函数。
绘制给定 text within the rectangle with origin ( x , y ), width and height .
boundingRect (if not null) is set to the actual bounding rectangle of the output. The flags argument is a bitwise OR of the following flags:
默认情况下, PySide.QtGui.QPainter 绘制抗锯齿文本。
注意
The y-position is used as the top of the font.
另请参阅
Qt.AlignmentFlag Qt.TextFlag
| 参数: |
|
|---|
这是重载函数。
绘制给定 text 在 rectangle specified using the option to control its positioning and orientation.
默认情况下, PySide.QtGui.QPainter 绘制抗锯齿文本。
注意
The y-coordinate of rectangle is used as the top of the font.
| 参数: |
|
|---|
绘制给定 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.
默认情况下, PySide.QtGui.QPainter 绘制抗锯齿文本。
注意
The y-position is used as the baseline of the font.
| 参数: |
|
|---|
这是重载函数。
绘制给定 text within the provided rectangle according to the specified flags 。 boundingRect (if not null) is set to the what the bounding rectangle should be in order to enclose the whole text.
默认情况下, PySide.QtGui.QPainter 绘制抗锯齿文本。
注意
The y-coordinate of rectangle is used as the top of the font.
| 参数: |
|
|---|
这是重载函数。
绘制给定 text with the currently defined text direction, beginning at the given position .
默认情况下, PySide.QtGui.QPainter 绘制抗锯齿文本。
注意
The y-position is used as the baseline of the font.
| 参数: |
|
|---|
这是重载函数。
| 参数: |
|---|
Draws the text item ti 在位置 p .
This method ignores the painters background mode and color. drawText and qt_format_text have to do it themselves, as only they know the extents of the complete string.
It ignores the font set on the painter as the text item has one of its own.
The underline and strikeout parameters of the text items font are ignored aswell. You'll need to pass in the correct flags to get underlining and strikeout.
| 参数: |
|---|
这是重载函数。
Draws the text item ti 在位置 p .
| 参数: |
|
|---|
Draws a tiled pixmap , inside the given rectangle with its origin at the given position .
调用 PySide.QtGui.QPainter.drawTiledPixmap() is similar to calling PySide.QtGui.QPainter.drawPixmap() several times to fill (tile) an area with a pixmap, but is potentially much more efficient depending on the underlying window system.
| 参数: |
|
|---|
这是重载函数。
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).
| 参数: |
|
|---|
这是重载函数。
Draws a tiled pixmap , inside the given rectangle with its origin at the given position .
| 返回类型: | PySide.QtCore.bool |
|---|
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.
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.
| 参数: | arg__1 – PySide.QtCore.QRectF |
|---|
Erases the area inside the given rectangle . Equivalent to calling
fillRect(rectangle, background())
| 参数: |
|
|---|
这是重载函数。
Erases the area inside the rectangle beginning at ( x , y ) with the given width and height .
| 参数: | arg__1 – PySide.QtCore.QRect |
|---|
这是重载函数。
Erases the area inside the given rectangle .
| 参数: |
|
|---|
Fills the given path using the given brush . The outline is not drawn.
Alternatively, you can specify a PySide.QtGui.QColor 而不是 PySide.QtGui.QBrush ; the PySide.QtGui.QBrush constructor (taking a PySide.QtGui.QColor argument) will automatically create a solid pattern brush.
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
这是重载函数。
Fills the rectangle beginning at ( x , y ) with the given width and height ,使用给定 brush .
| 参数: |
|
|---|
这是重载函数。
Fills the rectangle beginning at ( x , y ) with the given width and height ,使用给定 color .
| 参数: |
|
|---|
| 参数: |
|
|---|
这是重载函数。
Fills the given rectangle with the specified brush .
| 参数: |
|
|---|
这是重载函数。
Fills the given rectangle 采用 color 指定。
| 参数: |
|
|---|
| 参数: |
|
|---|
这是重载函数。
Fills the given rectangle 采用 color 指定。
| 参数: |
|
|---|
| 参数: |
|
|---|
Fills the given rectangle 采用 brush 指定。
Alternatively, you can specify a PySide.QtGui.QColor 而不是 PySide.QtGui.QBrush ; the PySide.QtGui.QBrush constructor (taking a PySide.QtGui.QColor argument) will automatically create a solid pattern brush.
| 返回类型: | PySide.QtGui.QFont |
|---|
Returns the currently set font used for drawing text.
| 返回类型: | PySide.QtGui.QFontInfo |
|---|
Returns the font info for the painter if the painter is active. Otherwise, the return value is undefined.
| 返回类型: | PySide.QtGui.QFontMetrics |
|---|
Returns the font metrics for the painter if the painter is active. Otherwise, the return value is undefined.
| 返回类型: | PySide.QtCore.bool |
|---|
Returns true if clipping has been set; otherwise returns false.
另请参阅
PySide.QtGui.QPainter.setClipping() Clipping
| 参数: | widget – PySide.QtGui.QWidget |
|---|
Initializes the painters pen, background and font to the same as the given widget . This function is called automatically when the painter is opened on a PySide.QtGui.QWidget .
另请参阅
| 返回类型: | PySide.QtCore.bool |
|---|
返回 true 若 PySide.QtGui.QPainter.begin() has been called and PySide.QtGui.QPainter.end() has not yet been called; otherwise returns false.
| 返回类型: | PySide.QtCore.Qt.LayoutDirection |
|---|
Returns the layout direction used by the painter when drawing text.
| 返回类型: | PySide.QtCore.qreal |
|---|
返回描绘器的不透明度。默认值为 1。
| 返回类型: | PySide.QtGui.QPaintEngine |
|---|
Returns the paint engine that the painter is currently operating on if the painter is active; otherwise 0.
| 返回类型: | PySide.QtGui.QPen |
|---|
返回描绘器的当前钢笔。
另请参阅
| 返回类型: | PySide.QtGui.QPainter.RenderHints |
|---|
Returns a flag that specifies the rendering hints that are set for this painter.
Resets any transformations that were made using PySide.QtGui.QPainter.translate() , PySide.QtGui.QPainter.scale() , PySide.QtGui.QPainter.shear() , PySide.QtGui.QPainter.rotate() , PySide.QtGui.QPainter.setWorldMatrix() , PySide.QtGui.QPainter.setViewport() and PySide.QtGui.QPainter.setWindow() .
It is advisable to use PySide.QtGui.QPainter.resetTransform() instead of this function to preserve the properties of perspective transformations.
另请参阅
Coordinate 变换
Resets any transformations that were made using PySide.QtGui.QPainter.translate() , PySide.QtGui.QPainter.scale() , PySide.QtGui.QPainter.shear() , PySide.QtGui.QPainter.rotate() , PySide.QtGui.QPainter.setWorldTransform() , PySide.QtGui.QPainter.setViewport() and PySide.QtGui.QPainter.setWindow() .
另请参阅
Coordinate 变换
Restores the current painter state (pops a saved state off the stack).
| 参数: | device – PySide.QtGui.QPaintDevice |
|---|
使用 QWidget.render() obsoletes the use of this function.
Restores the previous redirection for the given device after a call to PySide.QtGui.QPainter.setRedirected() .
警告
Making use of redirections in the PySide.QtGui.QPainter API implies that QPainter.begin() and PySide.QtGui.QPaintDevice destructors need to hold a mutex for a short period. This can impact performance. Use of QWidget::render is strongly encouraged.
另请参阅
PySide.QtGui.QPainter.redirected()
| 参数: | a – PySide.QtCore.qreal |
|---|
Rotates the coordinate system the given angle clockwise.
另请参阅
PySide.QtGui.QPainter.setWorldTransform() Coordinate 变换
Saves the current painter state (pushes the state onto a stack). A PySide.QtGui.QPainter.save() must be followed by a corresponding PySide.QtGui.QPainter.restore() ; the PySide.QtGui.QPainter.end() function unwinds the stack.
| 参数: |
|
|---|
Scales the coordinate system by ( sx , sy ).
另请参阅
PySide.QtGui.QPainter.setWorldTransform() Coordinate 变换
| 参数: | bg – PySide.QtGui.QBrush |
|---|
将描绘器背景笔刷设为给定 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).
| 参数: | mode – PySide.QtCore.Qt.BGMode |
|---|
| 参数: | brush – PySide.QtGui.QBrush |
|---|
把描绘器的笔刷设为给定 brush .
描绘器的笔刷定义形状如何被填充。
另请参阅
| 参数: | style – PySide.QtCore.Qt.BrushStyle |
|---|
| 参数: | arg__1 – PySide.QtCore.QPointF |
|---|
Sets the brush origin to position .
The brush origin specifies the (0, 0) coordinate of the painter's brush.
Note that while the PySide.QtGui.QPainter.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 PySide.QtGui.QWidget.autoFillBackground() property to true.
| 参数: | arg__1 – PySide.QtCore.QPoint |
|---|
这是重载函数。
Sets the brush's origin to the given position .
| 参数: |
|
|---|
这是重载函数。
Sets the brush's origin to point ( x , y ).
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: | enable – PySide.QtCore.bool |
|---|
Enables clipping if enable is true, or disables clipping if enable is false.
另请参阅
PySide.QtGui.QPainter.hasClipping() Clipping
| 参数: | mode – PySide.QtGui.QPainter.CompositionMode |
|---|
将合成模式设为给定 mode .
警告
Only a PySide.QtGui.QPainter operating on a PySide.QtGui.QImage fully supports all composition modes. The RasterOp modes are supported for X11 as described in PySide.QtGui.QPainter.compositionMode() .
| 参数: | f – PySide.QtGui.QFont |
|---|
Sets the painter's font to the given font .
This font is used by subsequent PySide.QtGui.QPainter.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. PySide.QtGui.QPainter.font() will return what you set using PySide.QtGui.QPainter.setFont() and PySide.QtGui.QPainter.fontInfo() returns the font actually being used (which may be the same).
| 参数: | direction – PySide.QtCore.Qt.LayoutDirection |
|---|
| 参数: | opacity – PySide.QtCore.qreal |
|---|
把描绘器的不透明度设为 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.
| 参数: | pen – PySide.QtGui.QPen |
|---|
把描绘器的钢笔,设为给定 pen .
pen 定义如何绘制线条和轮廓,且它还定义文本颜色。
另请参阅
| 参数: | color – PySide.QtGui.QColor |
|---|
这是重载函数。
Sets the painter's pen to have style Qt.SolidLine , width 0 and the specified color .
| 参数: | style – PySide.QtCore.Qt.PenStyle |
|---|
| 参数: |
|
|---|
Please use QWidget.render() 代替。
Redirects all paint commands for the given paint device , to the replacement device. The optional point offset defines an offset within the source device.
The redirection will not be effective until the PySide.QtGui.QPainter.begin() function has been called; make sure to call PySide.QtGui.QPainter.end() 为给定 device ‘s painter (if any) before redirecting. Call PySide.QtGui.QPainter.restoreRedirected() to restore the previous redirection.
警告
Making use of redirections in the PySide.QtGui.QPainter API implies that QPainter.begin() and PySide.QtGui.QPaintDevice destructors need to hold a mutex for a short period. This can impact performance. Use of QWidget::render is strongly encouraged.
另请参阅
PySide.QtGui.QPainter.redirected() PySide.QtGui.QPainter.restoreRedirected()
| 参数: |
|
|---|
Sets the given render hint on the painter if on is true; otherwise clears the render hint.
| 参数: |
|
|---|
| 参数: |
|
|---|
Sets the world transformation matrix. If combine is true, the specified transform is combined with the current matrix; otherwise it replaces the current matrix.
| 参数: | enable – PySide.QtCore.bool |
|---|
Enables view transformations if enable is true, or disables view transformations if enable is false.
另请参阅
PySide.QtGui.QPainter.viewTransformEnabled() Window-Viewport Conversion
| 参数: |
|
|---|
这是重载函数。
Sets the painter's viewport rectangle to be the rectangle beginning at ( x , y ) with the given width and height .
| 参数: | 视口 – PySide.QtCore.QRect |
|---|
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 PySide.QtGui.QPainter.window() , specifies the logical coordinate system.
The default viewport rectangle is the same as the device's rectangle.
另请参阅
PySide.QtGui.QPainter.viewport() PySide.QtGui.QPainter.viewTransformEnabled() Window-Viewport Conversion
| 参数: | window – PySide.QtCore.QRect |
|---|
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 PySide.QtGui.QPainter.viewport() , specifies the device coordinate system.
The default window rectangle is the same as the device's rectangle.
另请参阅
PySide.QtGui.QPainter.window() PySide.QtGui.QPainter.viewTransformEnabled() Window-Viewport Conversion
| 参数: |
|
|---|
这是重载函数。
Sets the painter's window to the rectangle beginning at ( x , y ) and the given width and height .
| 参数: |
|
|---|
Sets the transformation matrix to matrix and enables transformations.
注意
It is advisable to use PySide.QtGui.QPainter.setWorldTransform() instead of this function to preserve the properties of perspective transformations.
若 combine is true, then matrix is combined with the current transformation matrix; otherwise matrix replaces the current transformation matrix.
若 matrix is the identity matrix and combine is false, this function calls setWorldMatrixEnabled(false). (The identity matrix is the matrix where QMatrix.m11() and QMatrix.m22() are 1.0 and the rest are 0.0.)
The following functions can transform the coordinate system without using a PySide.QtGui.QMatrix :
They operate on the painter's PySide.QtGui.QPainter.worldMatrix() and are implemented like this:
def rotate(self, angle):
matrix = QMatrix()
matrix.rotate(angle)
setWorldMatrix(matrix, true)
Note that when using PySide.QtGui.QPainter.setWorldMatrix() function you should always have combine be true when you are drawing into a PySide.QtGui.QPicture . Otherwise it may not be possible to replay the picture with additional transformations; using the PySide.QtGui.QPainter.translate() , PySide.QtGui.QPainter.scale() , etc. convenience functions is safe.
For more information about the coordinate system, transformations and window-viewport conversion, see 坐标系统 .
| 参数: | enabled – PySide.QtCore.bool |
|---|
Enables transformations if enable is true, or disables transformations if enable is false. The world transformation matrix is not changed.
另请参阅
PySide.QtGui.QPainter.worldMatrixEnabled() PySide.QtGui.QPainter.worldTransform() Coordinate 变换
| 参数: |
|
|---|
Sets the world transformation matrix. If combine is true, the specified matrix is combined with the current matrix; otherwise it replaces the current matrix.
| 参数: |
|
|---|
Shears the coordinate system by ( sh , sv ).
另请参阅
PySide.QtGui.QPainter.setWorldTransform() Coordinate 变换
| 参数: |
|
|---|
Draws the outline (strokes) the path path with the pen specified by pen
另请参阅
| 参数: | hint – PySide.QtGui.QPainter.RenderHint |
|---|---|
| 返回类型: | PySide.QtCore.bool |
返回 true 若 hint is set; otherwise returns false.
| 返回类型: | PySide.QtGui.QTransform |
|---|
Returns the world transformation matrix.
| 参数: | offset – PySide.QtCore.QPointF |
|---|
Translates the coordinate system by the given offset ; i.e. the given offset is added to points.
另请参阅
PySide.QtGui.QPainter.setWorldTransform() Coordinate 变换
| 参数: | offset – PySide.QtCore.QPoint |
|---|
这是重载函数。
Translates the coordinate system by the given offset .
| 参数: |
|
|---|
这是重载函数。
Translates the coordinate system by the vector ( dx , dy ).
| 返回类型: | PySide.QtCore.bool |
|---|
Returns true if view transformation is enabled; otherwise returns false.
| 返回类型: | PySide.QtCore.QRect |
|---|
Returns the viewport rectangle.
| 返回类型: | PySide.QtCore.QRect |
|---|
Returns the window rectangle.
| 返回类型: | PySide.QtGui.QMatrix |
|---|
Returns the world transformation matrix.
It is advisable to use PySide.QtGui.QPainter.worldTransform() 因为 PySide.QtGui.QPainter.worldMatrix() does not preserve the properties of perspective transformations.
另请参阅
PySide.QtGui.QPainter.setWorldMatrix() Coordinate 变换 坐标系统
| 返回类型: | PySide.QtCore.bool |
|---|
Returns true if world transformation is enabled; otherwise returns false.
| 返回类型: | PySide.QtGui.QTransform |
|---|
Returns the world transformation matrix.