Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Friends | Related Functions

QPainter Class Reference

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

Inheritance diagram for QPainter:
Inheritance graph
[legend]
Collaboration diagram for QPainter:
Collaboration graph
[legend]

List of all members.

Public Types

enum  CompositionMode {
  CompositionMode_SourceOver, CompositionMode_DestinationOver, CompositionMode_Clear, CompositionMode_Source,
  CompositionMode_Destination, CompositionMode_SourceIn, CompositionMode_DestinationIn, CompositionMode_SourceOut,
  CompositionMode_DestinationOut, CompositionMode_SourceAtop, CompositionMode_DestinationAtop, CompositionMode_Xor,
  CompositionMode_Plus, CompositionMode_Multiply, CompositionMode_Screen, CompositionMode_Overlay,
  CompositionMode_Darken, CompositionMode_Lighten, CompositionMode_ColorDodge, CompositionMode_ColorBurn,
  CompositionMode_HardLight, CompositionMode_SoftLight, CompositionMode_Difference, CompositionMode_Exclusion,
  RasterOp_SourceOrDestination, RasterOp_SourceAndDestination, RasterOp_SourceXorDestination, RasterOp_NotSourceAndNotDestination,
  RasterOp_NotSourceOrNotDestination, RasterOp_NotSourceXorDestination, RasterOp_NotSource, RasterOp_NotSourceAndDestination,
  RasterOp_SourceAndNotDestination
}
enum  RenderHint {
  Antialiasing = 0x01, TextAntialiasing = 0x02, SmoothPixmapTransform = 0x04, HighQualityAntialiasing = 0x08,
  NonCosmeticDefaultPen = 0x10
}

Public Member Functions

const QBrushbackground () const
Qt::BGMode backgroundMode () const
bool begin (QPaintDevice *)
QRectF boundingRect (const QRectF &rect, int flags, const QString &text)
QRect boundingRect (const QRect &rect, int flags, const QString &text)
QRect boundingRect (int x, int y, int w, int h, int flags, const QString &text)
QRectF boundingRect (const QRectF &rect, const QString &text, const QTextOption &o=QTextOption())
const QBrushbrush () const
QPoint brushOrigin () const
QPainterPath clipPath () const
QRegion clipRegion () const
QMatrix combinedMatrix () const
QTransform combinedTransform () const
CompositionMode compositionMode () const
QPaintDevicedevice () const
const QMatrixdeviceMatrix () const
const QTransformdeviceTransform () const
void drawArc (const QRectF &rect, int a, int alen)
void drawArc (const QRect &, int a, int alen)
void drawArc (int x, int y, int w, int h, int a, int alen)
void drawChord (const QRectF &rect, int a, int alen)
void drawChord (int x, int y, int w, int h, int a, int alen)
void drawChord (const QRect &, int a, int alen)
void drawConvexPolygon (const QPointF *points, int pointCount)
void drawConvexPolygon (const QPolygonF &polygon)
void drawConvexPolygon (const QPoint *points, int pointCount)
void drawConvexPolygon (const QPolygon &polygon)
void drawEllipse (const QRectF &r)
void drawEllipse (const QRect &r)
void drawEllipse (int x, int y, int w, int h)
void drawEllipse (const QPointF &center, qreal rx, qreal ry)
void drawEllipse (const QPoint &center, int rx, int ry)
void drawImage (const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
void drawImage (const QRect &targetRect, const QImage &image, const QRect &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
void drawImage (const QPointF &p, const QImage &image, const QRectF &sr, Qt::ImageConversionFlags flags=Qt::AutoColor)
void drawImage (const QPoint &p, const QImage &image, const QRect &sr, Qt::ImageConversionFlags flags=Qt::AutoColor)
void drawImage (const QRectF &r, const QImage &image)
void drawImage (const QRect &r, const QImage &image)
void drawImage (const QPointF &p, const QImage &image)
void drawImage (const QPoint &p, const QImage &image)
void drawImage (int x, int y, const QImage &image, int sx=0, int sy=0, int sw=-1, int sh=-1, Qt::ImageConversionFlags flags=Qt::AutoColor)
void drawLine (const QLine &line)
void drawLine (int x1, int y1, int x2, int y2)
void drawLine (const QLineF &line)
void drawLine (const QPoint &p1, const QPoint &p2)
void drawLine (const QPointF &p1, const QPointF &p2)
void drawLines (const QLineF *lines, int lineCount)
void drawLines (const QVector< QLineF > &lines)
void drawLines (const QPointF *pointPairs, int lineCount)
void drawLines (const QVector< QPointF > &pointPairs)
void drawLines (const QLine *lines, int lineCount)
void drawLines (const QVector< QLine > &lines)
void drawLines (const QPoint *pointPairs, int lineCount)
void drawLines (const QVector< QPoint > &pointPairs)
void drawPath (const QPainterPath &path)
void drawPicture (const QPointF &p, const QPicture &picture)
void drawPicture (int x, int y, const QPicture &picture)
void drawPicture (const QPoint &p, const QPicture &picture)
void drawPie (const QRectF &rect, int a, int alen)
void drawPie (int x, int y, int w, int h, int a, int alen)
void drawPie (const QRect &, int a, int alen)
void drawPixmap (const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
void drawPixmap (const QRect &targetRect, const QPixmap &pixmap, const QRect &sourceRect)
void drawPixmap (int x, int y, int w, int h, const QPixmap &pm, int sx, int sy, int sw, int sh)
void drawPixmap (int x, int y, const QPixmap &pm, int sx, int sy, int sw, int sh)
void drawPixmap (const QPointF &p, const QPixmap &pm, const QRectF &sr)
void drawPixmap (const QPoint &p, const QPixmap &pm, const QRect &sr)
void drawPixmap (const QPointF &p, const QPixmap &pm)
void drawPixmap (const QPoint &p, const QPixmap &pm)
void drawPixmap (const QRect &r, const QPixmap &pm)
void drawPixmap (int x, int y, int w, int h, const QPixmap &pm)
void drawPixmap (int x, int y, const QPixmap &pm)
void drawPoint (const QPointF &pt)
void drawPoint (const QPoint &p)
void drawPoint (int x, int y)
void drawPoints (const QPointF *points, int pointCount)
void drawPoints (const QPolygonF &points)
void drawPoints (const QPoint *points, int pointCount)
void drawPoints (const QPolygon &points)
void drawPolygon (const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
void drawPolygon (const QPolygonF &polygon, Qt::FillRule fillRule=Qt::OddEvenFill)
void drawPolygon (const QPolygon &polygon, Qt::FillRule fillRule=Qt::OddEvenFill)
void drawPolygon (const QPoint *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
void drawPolyline (const QPointF *points, int pointCount)
void drawPolyline (const QPolygonF &polyline)
void drawPolyline (const QPolygon &polygon)
void drawPolyline (const QPoint *points, int pointCount)
void drawRect (const QRectF &rect)
void drawRect (int x1, int y1, int w, int h)
void drawRect (const QRect &rect)
void drawRects (const QRectF *rects, int rectCount)
void drawRects (const QVector< QRectF > &rectangles)
void drawRects (const QRect *rects, int rectCount)
void drawRects (const QVector< QRect > &rectangles)
void drawRoundedRect (const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode=Qt::AbsoluteSize)
void drawRoundedRect (int x, int y, int w, int h, qreal xRadius, qreal yRadius, Qt::SizeMode mode=Qt::AbsoluteSize)
void drawRoundedRect (const QRect &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode=Qt::AbsoluteSize)
void drawRoundRect (const QRectF &r, int xround=25, int yround=25)
void drawRoundRect (const QRect &r, int xround=25, int yround=25)
void drawRoundRect (int x, int y, int w, int h, int=25, int=25)
void drawText (const QPoint &p, const QString &s)
void drawText (int x, int y, const QString &s)
void drawText (const QPointF &p, const QString &s)
void drawText (const QPointF &p, const QString &str, int tf, int justificationPadding)
void drawText (const QRect &r, int flags, const QString &text, QRect *br=0)
void drawText (const QRectF &r, const QString &text, const QTextOption &o=QTextOption())
void drawText (const QRectF &r, int flags, const QString &text, QRectF *br=0)
void drawText (int x, int y, int w, int h, int flags, const QString &text, QRect *br=0)
void drawTextItem (const QPointF &p, const QTextItem &ti)
void drawTextItem (int x, int y, const QTextItem &ti)
void drawTextItem (const QPoint &p, const QTextItem &ti)
void drawTiledPixmap (const QRectF &rect, const QPixmap &pm, const QPointF &offset=QPointF())
void drawTiledPixmap (int x, int y, int w, int h, const QPixmap &, int sx=0, int sy=0)
void drawTiledPixmap (const QRect &, const QPixmap &, const QPoint &=QPoint())
bool end ()
void eraseRect (int x, int y, int w, int h)
void eraseRect (const QRectF &)
void eraseRect (const QRect &)
void fillPath (const QPainterPath &path, const QBrush &brush)
void fillRect (const QRect &, const QColor &color)
void fillRect (const QRectF &r, Qt::BrushStyle style)
void fillRect (const QRect &r, Qt::BrushStyle style)
void fillRect (const QRect &r, Qt::GlobalColor c)
void fillRect (const QRectF &, const QBrush &)
void fillRect (int x, int y, int w, int h, const QColor &color)
void fillRect (int x, int y, int w, int h, Qt::GlobalColor c)
void fillRect (const QRectF &r, Qt::GlobalColor c)
void fillRect (int x, int y, int w, int h, const QBrush &)
void fillRect (const QRect &, const QBrush &)
void fillRect (const QRectF &, const QColor &color)
void fillRect (int x, int y, int w, int h, Qt::BrushStyle style)
const QFontfont () const
QFontInfo fontInfo () const
QFontMetrics fontMetrics () const
bool hasClipping () const
void initFrom (const QWidget *widget)
bool isActive () const
Qt::LayoutDirection layoutDirection () const
const QMatrixmatrix () const
bool matrixEnabled () const
qreal opacity () const
QPaintEnginepaintEngine () const
const QPenpen () const
 QPainter (QPaintDevice *)
 QPainter ()
RenderHints renderHints () const
void resetMatrix ()
void resetTransform ()
void restore ()
void rotate (qreal a)
 [3]
void save ()
void scale (qreal sx, qreal sy)
void setBackground (const QBrush &bg)
void setBackgroundMode (Qt::BGMode mode)
void setBrush (const QBrush &brush)
void setBrush (Qt::BrushStyle style)
void setBrushOrigin (int x, int y)
void setBrushOrigin (const QPoint &)
void setBrushOrigin (const QPointF &)
void setClipPath (const QPainterPath &path, Qt::ClipOperation op=Qt::ReplaceClip)
void setClipping (bool enable)
void setClipRect (const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
void setClipRect (const QRect &, Qt::ClipOperation op=Qt::ReplaceClip)
void setClipRect (int x, int y, int w, int h, Qt::ClipOperation op=Qt::ReplaceClip)
void setClipRegion (const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
void setCompositionMode (CompositionMode mode)
void setFont (const QFont &f)
void setLayoutDirection (Qt::LayoutDirection direction)
void setMatrix (const QMatrix &matrix, bool combine=false)
void setMatrixEnabled (bool enabled)
void setOpacity (qreal opacity)
void setPen (Qt::PenStyle style)
void setPen (const QColor &color)
void setPen (const QPen &pen)
void setRenderHint (RenderHint hint, bool on=true)
void setRenderHints (RenderHints hints, bool on=true)
void setTransform (const QTransform &transform, bool combine=false)
void setViewport (const QRect &viewport)
void setViewport (int x, int y, int w, int h)
void setViewTransformEnabled (bool enable)
void setWindow (const QRect &window)
void setWindow (int x, int y, int w, int h)
void setWorldMatrix (const QMatrix &matrix, bool combine=false)
void setWorldMatrixEnabled (bool enabled)
void setWorldTransform (const QTransform &matrix, bool combine=false)
void shear (qreal sh, qreal sv)
void strokePath (const QPainterPath &path, const QPen &pen)
bool testRenderHint (RenderHint hint) const
const QTransformtransform () const
void translate (const QPoint &offset)
void translate (const QPointF &offset)
void translate (qreal dx, qreal dy)
QRect viewport () const
bool viewTransformEnabled () const
QRect window () const
const QMatrixworldMatrix () const
bool worldMatrixEnabled () const
const QTransformworldTransform () const
 ~QPainter ()

Static Public Member Functions

static QPaintDeviceredirected (const QPaintDevice *device, QPoint *offset=0)
static void restoreRedirected (const QPaintDevice *device)
static void setRedirected (const QPaintDevice *device, QPaintDevice *replacement, const QPoint &offset=QPoint())

Private Attributes

QPainterPrivated_ptr

Friends

class Q3Painter
class QAlphaPaintEngine
class QFontEngine
class QFontEngineBox
class QFontEngineFT
class QFontEngineMac
class QFontEngineWin
class QFontEngineXLFD
class QOpenGLPaintEngine
class QPaintEngine
class QPreviewPaintEngine
class QRasterPaintEngine
class QWin32PaintEngine
class QWin32PaintEnginePrivate
class QWSManager
class QX11PaintEngine
class QX11PaintEnginePrivate

Related Functions

(Note that these are not member functions.)


void qDrawPlainRect (QPainter *painter, int x, int y, int width, int height, const QColor &lineColor, int lineWidth, const QBrush *fill)
void qDrawPlainRect (QPainter *painter, const QRect &rect, const QColor &lineColor, int lineWidth, const QBrush *fill)
QT_BEGIN_NAMESPACEvoid qDrawShadeLine (QPainter *painter, int x1, int y1, int x2, int y2, const QPalette &palette, bool sunken, int lineWidth, int midLineWidth)
void qDrawShadeLine (QPainter *painter, const QPoint &p1, const QPoint &p2, const QPalette &palette, bool sunken, int lineWidth, int midLineWidth)
void qDrawShadePanel (QPainter *painter, const QRect &rect, const QPalette &palette, bool sunken, int lineWidth, const QBrush *fill)
void qDrawShadePanel (QPainter *painter, int x, int y, int width, int height, const QPalette &palette, bool sunken, int lineWidth, const QBrush *fill)
void qDrawShadeRect (QPainter *painter, int x, int y, int width, int height, const QPalette &palette, bool sunken, int lineWidth, int midLineWidth, const QBrush *fill)
void qDrawShadeRect (QPainter *painter, const QRect &rect, const QPalette &palette, bool sunken, int lineWidth, int midLineWidth, const QBrush *fill)
void qDrawWinButton (QPainter *painter, int x, int y, int width, int height, const QPalette &palette, bool sunken, const QBrush *fill)
void qDrawWinButton (QPainter *painter, const QRect &rect, const QPalette &palette, bool sunken, const QBrush *fill)
void qDrawWinPanel (QPainter *painter, int x, int y, int width, int height, const QPalette &palette, bool sunken, const QBrush *fill)

Detailed Description

The QPainter class performs low-level painting on widgets and other paint devices.

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:

doc/src/snippets/code/src_gui_painting_qpainter.cpp 0

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 Paint System} documentation.

Sometimes it is desirable to make someone else paint on an unusual QPaintDevice. QPainter supports a static function to do this, setRedirected().

Warning:
When the paintdevice is a widget, 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.

Definition at line 81 of file qpainter.h.


The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index