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

Static Public Members

Protected Members

Related Functions


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

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 QPaintDevice subclasses.

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

Qt::HANDLE 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.

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::x11AppCells () [static]

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

See also x11Colormap().

int QPaintDevice::x11AppCells ( int screen ) [static]

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

Returns the number of entries in the colormap for screen screen 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 for the default screen of the X display global to the application (X11 only). Using this function is not portable.

See also x11Cells().

Qt::HANDLE QPaintDevice::x11AppColormap ( int screen ) [static]

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

Returns the colormap for screen screen 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 for the default screen of the X display global to the application (X11 only). Using this function is not portable.

See also x11Cells().

bool QPaintDevice::x11AppDefaultColormap ( int screen ) [static]

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

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

See also x11Cells().

bool QPaintDevice::x11AppDefaultVisual () [static]

Returns TRUE if the Visual used is the default for the default screen of the X display global to the application (X11 only); otherwise returns FALSE. Using this function is not portable.

bool QPaintDevice::x11AppDefaultVisual ( int screen ) [static]

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

Returns TRUE if the Visual used is the default for screen screen of the X display global to the application (X11 only); otherwise returns FALSE. Using this function is not portable.

int QPaintDevice::x11AppDepth ( int screen ) [static]

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

See also QPixmap::defaultDepth().

int QPaintDevice::x11AppDepth () [static]

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

Returns the depth for the default screen 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 ( int screen ) [static]

Returns the horizontal DPI of the X display (X11 only) for screen screen. 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::x11AppDpiX () [static]

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

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

int QPaintDevice::x11AppDpiY ( int screen ) [static]

Returns the vertical DPI of the X11 display (X11 only) for screen screen. 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::x11AppDpiY () [static]

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

Returns the vertical DPI of the X11 display (X11 only) for the default screen. 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().

Qt::HANDLE QPaintDevice::x11AppRootWindow () [static]

Returns the root window for the default screen of the X display global to the applicatoin (X11 only). Using this function is not portable.

Qt::HANDLE QPaintDevice::x11AppRootWindow ( int screen ) [static]

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

Returns the root window for screen screen of the X display global to the applicatoin (X11 only). Using this function is not portable.

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 for the default screen of the X display global to the application (X11 only). Using this function is not portable.

void * QPaintDevice::x11AppVisual ( int screen ) [static]

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

Returns the Visual for screen screen 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, int screen ) [static]

Sets the value returned by x11AppDpiX() to dpi for screen screen. 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::x11SetAppDpiX ( int dpi ) [static]

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

Sets the value returned by x11AppDpiX() to dpi for the default screen. 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.

void QPaintDevice::x11SetAppDpiY ( int dpi, int screen ) [static]

Sets the value returned by x11AppDpiY() to dpi for screen screen. 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::x11SetAppDpiY ( int dpi ) [static]

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

Sets the value returned by x11AppDpiY() to dpi for the default screen. 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.

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 respectively, sy) and ending at the right end (respectively, 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-2003 Trolltech. All Rights Reserved.


Copyright © 2003 TrolltechTrademarks
Qt version 3.1.2