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 Functions

- virtual ~QPaintDevice ()
- bool isExtDev () const
- bool paintingActive () 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 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.

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

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