|  | Home · All Classes · Main Classes · Grouped Classes · Modules · Functions |

# Qt 3 Support Members for QPainter

The following class members are part of the Qt 3 support layer. They are provided to help you port old code to Qt 4. We advise against using them in new code.

- QPainter class reference

### Public Functions

- const QColor & backgroundColor () const
- bool begin ( QPaintDevice * pdev, const QWidget * init )
- QRect boundingRect ( const QRect & rect, int flags, const QString & text, int len )
- QRect boundingRect ( int x, int y, int w, int h, int flags, const QString & text, int len )
- void drawConvexPolygon ( const QPolygonF & polygon, int index, int npoints = -1 )
- void drawConvexPolygon ( const QPolygon & polygon, int index, int npoints = -1 )
- void drawCubicBezier ( const QPolygon & a, int index = 0 )
- void drawLineSegments ( const QPolygon & a, int index = 0, int nlines = -1 )
- void drawPoints ( const QPolygon & points, int index, int npoints = -1 )
- void drawPolygon ( const QPolygon & pa, bool winding, int index = 0, int npoints = -1 )
- void drawPolygon ( const QPolygonF & polygon, bool winding, int index = 0, int npoints = -1 )
- void drawPolyline ( const QPolygon & pa, int index, int npoints = -1 )
- void drawText ( int x, int y, const QString & text, int pos, int len )
- void drawText ( const QPoint & p, const QString & text, int pos, int len )
- void drawText ( int x, int y, const QString & text, int len )
- void drawText ( const QPoint & p, const QString & s, int len )
- void drawText ( const QRect & r, int flags, const QString & str, int len, QRect * br = 0 )
- void drawText ( int x, int y, int w, int h, int flags, const QString & str, int len, QRect * br = 0 )
- bool hasViewXForm () const
- bool hasWorldXForm () const
- void resetXForm ()
- void setBackgroundColor ( const QColor & color )
- void setViewXForm ( bool enabled )
- void setWorldMatrix ( const QMatrix & wm, bool combine = false )
- void setWorldXForm ( bool enabled )
- const QMatrix & worldMatrix () const
- QPoint xForm ( const QPoint & p ) const
- QRect xForm ( const QRect & r ) const
- QPolygon xForm ( const QPolygon & a ) const
- QPolygon xForm ( const QPolygon & av, int index, int npoints ) const
- QRect xFormDev ( const QRect & r ) const
- QPoint xFormDev ( const QPoint & p ) const
- QPolygon xFormDev ( const QPolygon & a ) const
- QPolygon xFormDev ( const QPolygon & ad, int index, int npoints ) const

### Static Public Members

- void redirect ( QPaintDevice * pdev, QPaintDevice * replacement )
- QPaintDevice * redirect ( QPaintDevice * pdev )

## Member Function Documentation

### const QColor & QPainter::backgroundColor () const

Use background().color() instead.

See also setBackgroundColor().

### bool QPainter::begin ( QPaintDevice * pdev, const QWidget * init )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

### QRect QPainter::boundingRect ( const QRect & rect, int flags, const QString & text, int len )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

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

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns the bounding rectangle of the first len characters of the given text constrained by the rectangle that begins at point (x, y) with width w and height h.

### void QPainter::drawConvexPolygon ( const QPolygonF & polygon, int index, int npoints = -1 )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

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

### void QPainter::drawConvexPolygon ( const QPolygon & polygon, int index, int npoints = -1 )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

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

### void QPainter::drawCubicBezier ( const QPolygon & a, int index = 0 )

Draws a cubic Bezier curve defined by the control points in a, starting at a[index] (index defaults to 0).

Control points after a[index + 3] are ignored. Nothing happens if there aren't enough control points.

### void QPainter::drawLineSegments ( const QPolygon & a, int index = 0, int nlines = -1 )

Draws nlines separate lines from points defined in a, starting at a[index] (index defaults to 0). If nlines is -1 (the default) all points until the end of the array are used (i.e. (a.size()-index)/2 lines are drawn).

Draws the 1st line from a[index] to a[index + 1]. Draws the 2nd line from a[index + 2] to a[index + 3] etc.

See also drawPolyline(), drawPolygon(), and QPen.

### void QPainter::drawPoints ( const QPolygon & points, int index, int npoints = -1 )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Draws npoints points in the polygon points starting on index using the current pen.

### void QPainter::drawPolygon ( const QPolygon & pa, bool winding, int index = 0, int npoints = -1 )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Draws the polygon defined by the points in the point array pa.

### void QPainter::drawPolygon ( const QPolygonF & polygon, bool winding, int index = 0, int npoints = -1 )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

### void QPainter::drawPolyline ( const QPolygon & pa, int index, int npoints = -1 )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Draws the polyline defined by the npoints points in pa starting at index. (index defaults to 0.)

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

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Use drawText(x, y, text.mid(pos, len)) instead.

### void QPainter::drawText ( const QPoint & p, const QString & text, int pos, int len )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Use drawText(p, text.mid(pos, len)) instead.

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

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Use drawText(x, y, text.left(len)) instead.

### void QPainter::drawText ( const QPoint & p, const QString & s, int len )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Use drawText(p, text.left(len)) instead.

### void QPainter::drawText ( const QRect & r, int flags, const QString & str, int len, QRect * br = 0 )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

### void QPainter::drawText ( int x, int y, int w, int h, int flags, const QString & str, int len, QRect * br = 0 )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Draws the string str within the rectangle with origin (x, y), width w and height h. If len is -1 (the default) all the text is drawn, otherwise only the first len characters are drawn. The flags that are given in the flags parameter are Qt::AlignmentFlags and Qt::TextFlags OR'd together. br (if not null) is set to the actual bounding rectangle of the output.

### bool QPainter::hasViewXForm () const

Use viewTransformEnabled() instead.

### bool QPainter::hasWorldXForm () const

Use matrixEnabled() instead.

### void QPainter::redirect ( QPaintDevice * pdev, QPaintDevice * replacement ) `[static]`

Use setRedirected() instead.

### QPaintDevice * QPainter::redirect ( QPaintDevice * pdev ) `[static]`

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Use redirected() instead.

### void QPainter::resetXForm ()

Use resetMatrix() instead.

### void QPainter::setBackgroundColor ( const QColor & color )

Use setBackground() instead.

See also backgroundColor().

### void QPainter::setViewXForm ( bool enabled )

Use setViewTransformEnabled() instead.

See also hasViewXForm().

### void QPainter::setWorldMatrix ( const QMatrix & wm, bool combine = false )

Use setMatrix() instead.

See also worldMatrix().

### void QPainter::setWorldXForm ( bool enabled )

Use setMatrixEnabled() instead.

See also hasWorldXForm().

### const QMatrix & QPainter::worldMatrix () const

Use matrix() instead.

See also setWorldMatrix().

### QPoint QPainter::xForm ( const QPoint & p ) const

Returns the point p transformed from model coordinates to device coordinates.

See also xFormDev() and QMatrix::map().

### QRect QPainter::xForm ( const QRect & r ) const

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns the rectangle r transformed from model coordinates to device coordinates.

If world transformation is enabled and rotation or shearing has been specified, then the bounding rectangle is returned.

See also xFormDev() and QMatrix::map().

### QPolygon QPainter::xForm ( const QPolygon & a ) const

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns the point array a transformed from model coordinates to device coordinates.

See also xFormDev() and QMatrix::map().

### QPolygon QPainter::xForm ( const QPolygon & av, int index, int npoints ) const

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns the point array av transformed from model coordinates to device coordinates. The index is the first point in the array and npoints denotes the number of points to be transformed. If npoints is negative, all points from av[index] until the last point in the array are transformed.

The returned point array consists of the number of points that were transformed.

Example:

        QPolygon a(10);
        QPolygon b;
        b = painter.xForm(a, 2, 4);  // b.size() == 4
        b = painter.xForm(a, 2, -1); // b.size() == 8

See also xFormDev() and QMatrix::map().

### QRect QPainter::xFormDev ( const QRect & r ) const

Returns the rectangle r transformed from device coordinates to model coordinates.

If world transformation is enabled and rotation or shearing is used, then the bounding rectangle is returned.

See also xForm() and QMatrix::map().

### QPoint QPainter::xFormDev ( const QPoint & p ) const

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns the point p transformed from device coordinates to model coordinates.

See also xForm() and QMatrix::map().

### QPolygon QPainter::xFormDev ( const QPolygon & a ) const

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns the point array a transformed from device coordinates to model coordinates.

See also xForm() and QMatrix::map().

### QPolygon QPainter::xFormDev ( const QPolygon & ad, int index, int npoints ) const

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns the point array ad transformed from device coordinates to model coordinates. The index is the first point in the array and npoints denotes the number of points to be transformed. If npoints is negative, all points from ad[index] until the last point in the array are transformed.

The returned point array consists of the number of points that were transformed.

Example:

        QPolygon a(10);
        QPolygon b;
        b = painter.xFormDev(a, 1, 3);  // b.size() == 3
        b = painter.xFormDev(a, 1, -1); // b.size() == 9

See also xForm() and QMatrix::map().