Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QPaintDevice Class Reference

The QPaintDevice class is the base class of objects that can be painted. More...

`#include <qpaintdevice.h>`

Inherited by QPixmap, QWidget, QPicture and QPrinter.

List of all member functions.

## Public Members

- virtual ~QPaintDevice ()
- int devType () const
- bool isExtDev () const
- bool paintingActive () const
- virtual HDC handle () const
- Display * x11Display () const
- int x11Screen () const
- int x11Depth () const
- int x11Cells () const
- Qt::HANDLE x11Colormap () const
- bool x11DefaultColormap () const
- void * x11Visual () const
- bool x11DefaultVisual () const

## Static Public Members

- Display * x11AppDisplay ()
- int x11AppScreen ()
- int x11AppDepth ()
- int x11AppCells ()
- int x11AppDpiX ()
- int x11AppDpiY ()
- Qt::HANDLE x11AppColormap ()
- bool x11AppDefaultColormap ()
- void * x11AppVisual ()
- bool x11AppDefaultVisual ()
- void x11SetAppDpiX ( int dpi )
- void x11SetAppDpiY ( int dpi )

## Protected Members

- QPaintDevice ( uint devflags )
- virtual bool cmd ( int, QPainter *, QPDevCmdParam * )
- virtual int metric ( int ) const

## 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 )
- void bitBlt ( QPaintDevice * dst, const QPoint & dp, const QPaintDevice * src, const QRect & sr, RasterOp rop )

## Detailed Description

The QPaintDevice class is 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 downward. 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 the widget
        p.setPen( red );                  // red outline
        p.setBrush( yellow );             // yellow fill
        p.drawEllipse( 10, 20, 100,100 ); // 100x100 ellipse at positin (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.

See also Graphics Classes and Image Processing Classes.

## Member Function Documentation

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

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

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

Destroys 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).

### int QPaintDevice::devType () const

Returns the device type identifier, which is `QInternal::Widget` if the device is a QWidget, `QInternal::Pixmap` if it's a QPixmap, `QInternal::Printer` if it's a QPrinter, `QInternal::Picture` if it's a QPicture or `QInternal::UndefinedDevice` in other cases (which should never happen).

### HDC QPaintDevice::handle () const`[virtual]`

Returns the window system handle of the paint device, for low-level access. Using this function is not portable.

The HANDLE type varies with platform; see qpaintdevice.h and qwindowdefs.h for details.

See also x11Display().

### bool QPaintDevice::isExtDev () const

Returns TRUE if the device is an external paint device; otherwise returns FALSE.

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 QPixmap, QWidget and QPicture.

### bool QPaintDevice::paintingActive () const

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

See also QPainter::isActive().

### int QPaintDevice::x11AppCells ()`[static]`

Returns the number of entries in the colormap of the X display global to the application (X11 only). Using this function is not portable.

See also x11Colormap().

### Qt::HANDLE QPaintDevice::x11AppColormap ()`[static]`

Returns the colormap of the X display global to the application (X11 only). Using this function is not portable.

See also x11Cells().

### bool QPaintDevice::x11AppDefaultColormap ()`[static]`

Returns the default colormap of the X display global to the application (X11 only). Using this function is not portable.

See also x11Cells().

### bool QPaintDevice::x11AppDefaultVisual ()`[static]`

Returns the default Visual of the X display global to the application (X11 only). Using this function is not portable.

### int QPaintDevice::x11AppDepth ()`[static]`

Returns the depth of the X display global to the application (X11 only). Using this function is not portable.

See also QPixmap::defaultDepth().

### Display * QPaintDevice::x11AppDisplay ()`[static]`

Returns a pointer to the X display global to the application (X11 only). Using this function is not portable.

See also handle().

### int QPaintDevice::x11AppDpiX ()`[static]`

Returns the horizontal DPI of the X display (X11 only). Using this function is not portable. See QPaintDeviceMetrics for portable access to related information. Using this function is not portable.

See also x11AppDpiY(), x11SetAppDpiX() and QPaintDeviceMetrics::logicalDpiX().

### int QPaintDevice::x11AppDpiY ()`[static]`

Returns the vertical DPI of the X11 display (X11 only). Using this function is not portable. See QPaintDeviceMetrics for portable access to related information. Using this function is not portable.

See also x11AppDpiX(), x11SetAppDpiY() and QPaintDeviceMetrics::logicalDpiY().

### int QPaintDevice::x11AppScreen ()`[static]`

Returns the screen number on the X display global to the application (X11 only). Using this function is not portable.

### void * QPaintDevice::x11AppVisual ()`[static]`

Returns the Visual of the X display global to the application (X11 only). Using this function is not portable.

### int QPaintDevice::x11Cells () const

Returns the number of entries in the colormap of the X display for the paint device (X11 only). Using this function is not portable.

See also x11Colormap().

### Qt::HANDLE QPaintDevice::x11Colormap () const

Returns the colormap of the X display for the paint device (X11 only). Using this function is not portable.

See also x11Cells().

### bool QPaintDevice::x11DefaultColormap () const

Returns the default colormap of the X display for the paint device (X11 only). Using this function is not portable.

See also x11Cells().

### bool QPaintDevice::x11DefaultVisual () const

Returns the default Visual of the X display for the paint device (X11 only). Using this function is not portable.

### int QPaintDevice::x11Depth () const

Returns the depth of the X display for the paint device (X11 only). Using this function is not portable.

See also QPixmap::defaultDepth().

### Display * QPaintDevice::x11Display () const

Returns a pointer to the X display for the paint device (X11 only). Using this function is not portable.

See also handle().

### int QPaintDevice::x11Screen () const

Returns the screen number on the X display for the paint device (X11 only). Using this function is not portable.

### void QPaintDevice::x11SetAppDpiX ( int dpi )`[static]`

Sets the value returned by x11AppDpiX() to dpi. The default is determined by the display configuration. Changing this value will alter the scaling of fonts and many other metrics and is not recommended. Using this function is not portable.

See also x11SetAppDpiY().

### void QPaintDevice::x11SetAppDpiY ( int dpi )`[static]`

Sets the value returned by x11AppDpiY() to dpi. The default is determined by the display configuration. Changing this value will alter the scaling of fonts and many other metrics and is not recommended. Using this function is not portable.

See also x11SetAppDpiX().

### void * QPaintDevice::x11Visual () const

Returns the Visual of the X display for the paint device (X11 only). Using this function is not portable.

## 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 )

Copies a block of pixels from src to dst, perhaps merging each pixel according to the raster operation rop. sx, sy is the top-left pixel in src (0, 0) by default, dx, dy is the top-left position in dst and sw, sh is the size of the copied block (all of src by default).

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

If ignoreMask is TRUE (the default is FALSE) and src is a masked QPixmap, the entire blit is masked by src->mask().

If src, dst, sw or sh is 0, bitBlt() does nothing. If sw or sh is negative bitBlt() copies starting at sx (and resp. sy) and ending at the right end (resp. bottom) of src.

src must be a QWidget or QPixmap. You cannot blit from a QPrinter, for example. bitBlt() does nothing if you attempt to blit from an unsupported device.

bitBlt() does nothing if src has a greater depth than dst. If you need to, for example, draw a 24-bit pixmap on an 8-bit widget, you must use drawPixmap().

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

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

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

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