Qt Reference Documentation

# Obsolete Members for QPainter

The following class members are obsolete. They are provided to keep old source code working. We strongly advise against using them in new code.

- QPainter class reference

## Public Functions

QMatrix | combinedMatrix () const`(obsolete)`
const QMatrix & | deviceMatrix () const`(obsolete)`
void | drawRoundRect ( const QRectF & r, int xRnd = 25, int yRnd = 25 )`(obsolete)`
void | drawRoundRect ( const QRect & r, int xRnd = 25, int yRnd = 25 )`(obsolete)`
void | drawRoundRect ( int x, int y, int w, int h, int xRnd = 25, int yRnd = 25 )`(obsolete)`
const QMatrix & | matrix () const`(obsolete)`
bool | matrixEnabled () const`(obsolete)`
void | resetMatrix ()`(obsolete)`
void | setMatrix ( const QMatrix & matrix, bool combine = false )`(obsolete)`
void | setMatrixEnabled ( bool enable )`(obsolete)`
void | setWorldMatrix ( const QMatrix & matrix, bool combine = false )`(obsolete)`
const QMatrix & | worldMatrix () const`(obsolete)`

## Static Public Members

QPaintDevice * | redirected ( const QPaintDevice * device, QPoint * offset = 0 )`(obsolete)`
void | restoreRedirected ( const QPaintDevice * device )`(obsolete)`
void | setRedirected ( const QPaintDevice * device, QPaintDevice * replacement, const QPoint & offset = QPoint() )`(obsolete)`

## Member Function Documentation

### QMatrix QPainter::combinedMatrix () const

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

It is advisable to use combinedTransform() instead of this function to preserve the properties of perspective transformations.

This function was introduced in Qt 4.2.

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

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

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

Note: It is advisable to use deviceTransform() instead of this function to preserve the properties of perspective transformations.

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.

See also worldMatrix() and QPaintEngine::hasFeature().

### void QPainter::drawRoundRect ( const QRectF & r, int xRnd = 25, int yRnd = 25 )

Draws a rectangle r with rounded corners.

The 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.

See also drawRoundedRect().

### void QPainter::drawRoundRect ( const QRect & r, int xRnd = 25, int yRnd = 25 )

This is an overloaded function.

Draws the rectangle r with rounded corners.

### void QPainter::drawRoundRect ( int x, int y, int w, int h, int xRnd = 25, int yRnd = 25 )

This is an overloaded function.

Draws the rectangle x, y, w, h with rounded corners.

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

Use worldTransform() instead.

See also setMatrix() and worldTransform().

### bool QPainter::matrixEnabled () const

Use worldMatrixEnabled() instead

See also setMatrixEnabled() and worldMatrixEnabled().

### QPaintDevice * QPainter::redirected ( const QPaintDevice * device, QPoint * offset = 0 )`[static]`

Using QWidget::render() obsoletes the use of this function.

Returns the replacement for given device. The optional out parameter offset returns the offset within the replaced device.

Warning: Making use of redirections in the QPainter API implies that QPainter::begin() and QPaintDevice destructors need to hold a mutex for a short period. This can impact performance. Use of QWidget::render is strongly encouraged.

Note: This function is thread-safe.

See also setRedirected() and restoreRedirected().

### void QPainter::resetMatrix ()

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

It is advisable to use resetTransform() instead of this function to preserve the properties of perspective transformations.

See also Coordinate Transformations.

### void QPainter::restoreRedirected ( const QPaintDevice * device )`[static]`

Using QWidget::render() obsoletes the use of this function.

Restores the previous redirection for the given device after a call to setRedirected().

Warning: Making use of redirections in the QPainter API implies that QPainter::begin() and QPaintDevice destructors need to hold a mutex for a short period. This can impact performance. Use of QWidget::render is strongly encouraged.

Note: This function is thread-safe.

See also redirected().

### void QPainter::setMatrix ( const QMatrix & matrix, bool combine = false )

Use setWorldTransform() instead.

See also matrix() and setWorldTransform().

### void QPainter::setMatrixEnabled ( bool enable )

Use setWorldMatrixEnabled() instead.

See also matrixEnabled() and setWorldMatrixEnabled().

### void QPainter::setRedirected ( const QPaintDevice * device, QPaintDevice * replacement, const QPoint & offset = QPoint() )`[static]`

Please use QWidget::render() instead.

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 begin() function has been called; make sure to call end() for the given device's painter (if any) before redirecting. Call restoreRedirected() to restore the previous redirection.

Warning: Making use of redirections in the QPainter API implies that QPainter::begin() and QPaintDevice destructors need to hold a mutex for a short period. This can impact performance. Use of QWidget::render is strongly encouraged.

Note: This function is thread-safe.

See also redirected() and restoreRedirected().

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

Sets the transformation matrix to matrix and enables transformations.

Note: It is advisable to use setWorldTransform() instead of this function to preserve the properties of perspective transformations.

If combine is true, then matrix is combined with the current transformation matrix; otherwise matrix replaces the current transformation matrix.

If 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 QMatrix:

- translate()
- scale()
- shear()
- rotate()

They operate on the painter's worldMatrix() and are implemented like this:

     void QPainter::rotate(qreal angle)
     {
         QMatrix matrix;
         matrix.rotate(angle);
         setWorldMatrix(matrix, true);
     }

Note that when using setWorldMatrix() function you should always have combine be true when you are drawing into a QPicture. Otherwise it may not be possible to replay the picture with additional transformations; using the translate(), scale(), etc. convenience functions is safe.

For more information about the coordinate system, transformations and window-viewport conversion, see Coordinate System.

This function was introduced in Qt 4.2.

See also worldMatrix(), setWorldTransform(), and QTransform.

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

Returns the world transformation matrix.

It is advisable to use worldTransform() because worldMatrix() does not preserve the properties of perspective transformations.

This function was introduced in Qt 4.2.

See also setWorldMatrix(), Coordinate Transformations, and Coordinate System.