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>

Inherited by QPicture, QPixmap, QWidget, and QPrinter.

- List of all members, including inherited members
- Compatibility members

### Public Types

- enum PaintDeviceMetric { PdmWidth, PdmHeight, PdmWidthMM, PdmHeightMM, PdmNumColors, ..., PdmPhysicalDpiY }

### Public Functions

- virtual ~QPaintDevice ()
- int depth () const
- int height () const
- int heightMM () const
- bool isExtDev () const
- int logicalDpiX () const
- int logicalDpiY () const
- int numColors () const
- bool paintingActive () const
- int width () const
- int widthMM () const

### Protected Functions

- QPaintDevice ( uint devflags )

## 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, using QPainter::setMatrix().

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 position (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 exists 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 Type Documentation

### enum QPaintDevice::PaintDeviceMetric

## Member Function Documentation

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

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

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

Destroys the paint device and frees window system resources.

### int QPaintDevice::depth () const

Returns the bit depth (number of bit planes) of the paint device.

### int QPaintDevice::height () const

Returns the height of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget).

### int QPaintDevice::heightMM () const

Returns the height of the paint device, measured in millimeters.

### 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::logicalDpiX () const

Returns the horizontal resolution of the device in dots per inch, which is used when computing font sizes. For X, this is usually the same as could be computed from widthMM(), but it varies on Windows.

### int QPaintDevice::logicalDpiY () const

Returns the vertical resolution of the device in dots per inch, which is used when computing font sizes. For X, this is usually the same as could be computed from heightMM(), but it varies on Windows.

### int QPaintDevice::numColors () const

Returns the number of different colors available for the paint device. Since this value is an int will not be sufficient to represent the number of colors on 32 bit displays, in which case INT_MAX is returned instead.

### bool QPaintDevice::paintingActive () const

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

See also QPainter::isActive().

### int QPaintDevice::width () const

Returns the width of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget).

### int QPaintDevice::widthMM () const

Returns the width of the paint device, measured in millimeters.