a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none }body { background: white; color: black; } -->

| Classes - Annotated - Tree - Functions - Home - Structure Qte

# QPaintDevice Class Reference

The base class of objects that can be painted. More...

`#include <qpaintdevice.h>`

Inherited by QPicture, QPixmap, QPrinter and QWidget.

List of all member functions.

## Public Members

- virtual ~QPaintDevice ()
- int devType () const
- bool isExtDev () const
- bool paintingActive () const
- enum PDevCmd { PdcNOP = 0, PdcDrawPoint = 1, PdcDrawFirst = PdcDrawPoint, PdcMoveTo = 2, PdcLineTo = 3, PdcDrawLine = 4, PdcDrawRect = 5, PdcDrawRoundRect = 6, PdcDrawEllipse = 7, PdcDrawArc = 8, PdcDrawPie = 9, PdcDrawChord = 10, PdcDrawLineSegments = 11, PdcDrawPolyline = 12, PdcDrawPolygon = 13, PdcDrawQuadBezier = 14, PdcDrawText = 15, PdcDrawTextFormatted = 16, PdcDrawPixmap = 17, PdcDrawImage = 18, PdcDrawText2 = 19, PdcDrawText2Formatted = 20, PdcDrawLast = PdcDrawText2Formatted, PdcBegin = 30, PdcEnd = 31, PdcSave = 32, PdcRestore = 33, PdcSetdev = 34, PdcSetBkColor = 40, PdcSetBkMode = 41, PdcSetROP = 42, PdcSetBrushOrigin = 43, PdcSetFont = 45, PdcSetPen = 46, PdcSetBrush = 47, PdcSetTabStops = 48, PdcSetTabArray = 49, PdcSetUnit = 50, PdcSetVXform = 51, PdcSetWindow = 52, PdcSetViewport = 53, PdcSetWXform = 54, PdcSetWMatrix = 55, PdcSaveWMatrix = 56, PdcRestoreWMatrix = 57, PdcSetClip = 60, PdcSetClipRegion = 61, PdcReservedStart = 0, PdcReservedStop = 199 }

## Protected Members

- QPaintDevice ( uint devflags )
- virtual bool cmd ( int, QPainter *, QPDevCmdParam * )
- virtual int metric ( int ) const
- virtual int fontMet ( QFont *, int, const char * = 0, int = 0 ) const
- virtual int fontInf ( QFont *, int ) const

## Related Functions

(Note that these are not member functions.)

- void bitBlt (QPaintDevice * dst, int dx, int dy, const QPaintDevice * src, int sx, int sy, int sw, int sh, Qt::RasterOp rop, bool ignoreMask)
- void bitBlt (QPaintDevice * dst, const QPoint & dp, const QPaintDevice * src, const QRect & sr, RasterOp rop)

## Detailed Description

The base class of objects that can be painted.

A paint device is an abstraction of a two-dimensional space that can be drawn using a QPainter. The drawing capabilities are implemented by the subclasses: QWidget, QPixmap, QPicture and QPrinter.

The default coordinate system of a paint device has its origin located at the top left position. X increases to the right and Y increases downwards. The unit is one pixel. There are several ways to set up a user-defined coordinate system using the painter, for example by QPainter::setWorldMatrix().

Example (draw on a paint device):

        void MyWidget::paintEvent( QPaintEvent * )
        {
            QPainter p;                             // our painter
            p.begin( this );                        // start painting widget
            p.setPen( red );                        // blue outline
            p.setBrush( yellow );                   // yellow fill
            p.drawEllipse( 10,20, 100,100 );        // 100x100 ellipse at 10,20
            p.end();                                // painting done
        }

The bit block transfer is an extremely useful operation for copying pixels from one paint device to another (or to itself). It is implemented as the global function bitBlt().

Example (scroll widget contents 10 pixels to the right):

        bitBlt( myWidget, 10,0, myWidget );

Warning: Qt requires that a QApplication object must exist before any paint devices can be created. Paint devices access window system resources, and these resources are not initialized before an application object is created.

## Member Function Documentation

### QPaintDevice::QPaintDevice ( uint devflags ) `[protected]`

Constructs a paint device with internal flags devflags. This constructor can only be invoked from subclasses of QPaintDevice.

### QPaintDevice::~QPaintDevice () `[virtual]`

Destructs the paint device and frees window system resources.

### bool QPaintDevice::cmd ( int, QPainter *, QPDevCmdParam * ) `[virtual protected]`

Internal virtual function that interprets drawing commands from the painter.

Implemented by subclasses that have no direct support for drawing graphics (external paint devices, for example QPicture).

Reimplemented in QPicture and QPrinter.

### int QPaintDevice::devType () const

Returns the device type identifier: `QInternal::Widget, QInternal::Pixmap, QInternal::Printer, QInternal::Picture` or `QInternal::UndefinedDevice.`

### int QPaintDevice::fontInf ( QFont *, int ) const `[virtual protected]`

Internal virtual function. Reserved for future use.

### int QPaintDevice::fontMet ( QFont *, int, const char * = 0, int = 0 ) const `[virtual protected]`

Internal virtual function. Reserved for future use.

### bool QPaintDevice::isExtDev () const

Returns TRUE if the device is a so-called external paint device.

External paint devices cannot be bitBlt()'ed from. QPicture and QPrinter are external paint devices.

### int QPaintDevice::metric ( int ) const `[virtual protected]`

Internal virtual function that returns paint device metrics.

Please use the QPaintDeviceMetrics class instead.

Reimplemented in QWidget, QPrinter, QPixmap and QPicture.

### bool QPaintDevice::paintingActive () const

Returns TRUE if the device is being painted, i.e. someone has called QPainter::begin() and not yet QPainter::end() for this device.

See also QPainter::isActive().

## Related Functions

### void bitBlt (QPaintDevice * dst, int dx, int dy, const QPaintDevice * src, int sx, int sy, int sw, int sh, Qt::RasterOp rop, bool ignoreMask)

This function copies a block of pixels from one paint device to another (bitBlt means bit block transfer).

Arguments:

- dst is the paint device to copy to.
- dx and dy is the position to copy to.
- src is the paint device to copy from.
- sx and sy is the position to copy from.
- sw and sh is the width and height of the block to be copied.
- rop defines the raster operation to be used when copying.

If sw is 0 or sh is 0, then bitBlt will do nothing.

If sw is negative, then bitBlt calculates `sw = src->width - sx.` If sh is negative, then bitBlt calculates `sh = src->height - sy.`

The most common values for rop are CopyROP and XorROP; the Qt::RasterOp documentation defines all the possible values.

The ignoreMask argument (default FALSE) applies where src is a QPixmap with a mask. If ignoreMask is TRUE, bitBlt ignores the pixmap's mask.

BitBlt has two restrictions:

1. The src device must be QWidget or QPixmap. You cannot copy pixels from a picture or a printer (external device).
2. The src device may not have pixel depth greater than dst. You cannot copy from an 8 bit pixmap to a 1 bit pixmap.

Examples: xform/xform.cpp desktop/desktop.cpp

### void bitBlt (QPaintDevice * dst, const QPoint & dp, const QPaintDevice * src, const QRect & sr, RasterOp rop)

Overloaded bitBlt() with the destination point dp and source rectangle sr.

Search the documentation, FAQ, qt-interest archive and more (uses www.trolltech.com):

This file is part of the Qt toolkit, copyright © 1995-2005 Trolltech, all rights reserved.