QPaintDevice Class Reference

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

  1. #include <QPaintDevice>

Inherited by: QCustomRasterPaintDevice, QGLFramebufferObject, QGLPixelBuffer, QImage, QPicture, QPixmap, QPrinter, QSvgGenerator, and QWidget.

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. Its default coordinate system has its origin located at the top-left position. X increases to the right and Y increases downwards. The unit is one pixel.

The drawing capabilities of QPaintDevice are currently implemented by the QWidget, QImage, QPixmap, QGLPixelBuffer, QPicture, and QPrinter subclasses.

To implement support for a new backend, you must derive from QPaintDevice and reimplement the virtual paintEngine() function to tell QPainter which paint engine should be used to draw on this particular device. Note that you also must create a corresponding paint engine to be able to draw on the device, i.e derive from QPaintEngine and reimplement its virtual functions.

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.

The QPaintDevice class provides several functions returning the various device metrics: The depth() function returns its bit depth (number of bit planes). The height() function returns its height in default coordinate system units (e.g. pixels for QPixmap and QWidget) while heightMM() returns the height of the device in millimeters. Similiarily, the width() and widthMM() functions return the width of the device in default coordinate system units and in millimeters, respectively. Alternatively, the protected metric() function can be used to retrieve the metric information by specifying the desired PaintDeviceMetric as argument.

The logicalDpiX() and logicalDpiY() functions return the horizontal and vertical resolution of the device in dots per inch. The physicalDpiX() and physicalDpiY() functions also return the resolution of the device in dots per inch, but note that if the logical and physical resolution differ, the corresponding QPaintEngine must handle the mapping. Finally, the colorCount() function returns the number of different colors available for the paint device.

See also QPaintEngine, QPainter, Coordinate System, and Paint System.

Public Types

Toggle detailsenum QPaintDevice::

PaintDeviceMetricPaintDeviceMetric { PdmWidth , PdmHeight , PdmWidthMM , PdmHeightMM , PdmNumColors , PdmDepth , PdmDpiX , PdmDpiY , PdmPhysicalDpiX , PdmPhysicalDpiY 10 ...} { PdmWidth , PdmHeight , PdmWidthMM , PdmHeightMM , PdmNumColors , PdmDepth , PdmDpiX , PdmDpiY , PdmPhysicalDpiX , PdmPhysicalDpiY 10 }

Describes the various metrics of a paint device.

ConstantValueDescription
QPaintDevice::PdmWidth 1 The width of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget). See also width().
QPaintDevice::PdmHeight 2 The height of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget). See also height().
QPaintDevice::PdmWidthMM 3 The width of the paint device in millimeters. See also widthMM().
QPaintDevice::PdmHeightMM 4 The height of the paint device in millimeters. See also heightMM().
QPaintDevice::PdmNumColors 5 The number of different colors available for the paint device. See also colorCount().
QPaintDevice::PdmDepth 6 The bit depth (number of bit planes) of the paint device. See also depth().
QPaintDevice::PdmDpiX 7 The horizontal resolution of the device in dots per inch. See also logicalDpiX().
QPaintDevice::PdmDpiY 8 The vertical resolution of the device in dots per inch. See also logicalDpiY().
QPaintDevice::PdmPhysicalDpiX 9 The horizontal resolution of the device in dots per inch. See also physicalDpiX().
QPaintDevice::PdmPhysicalDpiY 10 The vertical resolution of the device in dots per inch. See also physicalDpiY().

See also metric().

Look up this member in the source code.

    Public Functions

    Toggle details QPaintDevice

    QPaintDeviceQPaintDevice () ()[protected]

    Constructs a paint device. This constructor can be invoked only from subclasses of QPaintDevice.

    Look up this member in the source code.

    Toggle details QPaintDevice

    ~QPaintDevice~QPaintDevice () () [virtual]

    Destroys the paint device and frees window system resources.

    Look up this member in the source code.

    Toggle details int QPaintDevice

    colorCountcolorCount () ()const

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

    Look up this member in the source code.

    Toggle details int QPaintDevice

    depthdepth () ()const

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

    Look up this member in the source code.

    Toggle details int QPaintDevice

    heightheight () ()const

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

    See also heightMM().

    Look up this member in the source code.

    Toggle details int QPaintDevice

    heightMMheightMM () ()const

    Returns the height of the paint device in millimeters. Due to platform limitations it may not be possible to use this function to determine the actual physical size of a widget on the screen.

    See also height().

    Look up this member in the source code.

    Toggle details int QPaintDevice

    logicalDpiXlogicalDpiX () ()const

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

    Note that if the logicalDpiX() doesn't equal the physicalDpiX(), the corresponding QPaintEngine must handle the resolution mapping.

    See also logicalDpiY() and physicalDpiX().

    Look up this member in the source code.

    Toggle details int QPaintDevice

    logicalDpiYlogicalDpiY () ()const

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

    Note that if the logicalDpiY() doesn't equal the physicalDpiY(), the corresponding QPaintEngine must handle the resolution mapping.

    See also logicalDpiX() and physicalDpiY().

    Look up this member in the source code.

    Toggle details int QPaintDevice

    metricmetric ( PaintDeviceMetric metric ) ( PaintDeviceMetric metric )const [virtual protected]

    Returns the metric information for the given paint device metric.

    See also PaintDeviceMetric.

    Look up this member in the source code.

    Toggle details int QPaintDevice

    numColorsnumColors () ()const

    Use colorCount() instead.

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

    Look up this member in the source code.

    Toggle details QPaintEngine * QPaintDevice

    paintEnginepaintEngine () ()const [pure virtual]

    Returns a pointer to the paint engine used for drawing on the device.

    Look up this member in the source code.

    Toggle details bool QPaintDevice

    paintingActivepaintingActive () ()const

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

    See also QPainter::isActive().

    Look up this member in the source code.

    Toggle details int QPaintDevice

    physicalDpiXphysicalDpiX () ()const

    Returns the horizontal resolution of the device in dots per inch. For example, when printing, this resolution refers to the physical printer's resolution. The logical DPI on the other hand, refers to the resolution used by the actual paint engine.

    Note that if the physicalDpiX() doesn't equal the logicalDpiX(), the corresponding QPaintEngine must handle the resolution mapping.

    See also physicalDpiY() and logicalDpiX().

    Look up this member in the source code.

    Toggle details int QPaintDevice

    physicalDpiYphysicalDpiY () ()const

    Returns the horizontal resolution of the device in dots per inch. For example, when printing, this resolution refers to the physical printer's resolution. The logical DPI on the other hand, refers to the resolution used by the actual paint engine.

    Note that if the physicalDpiY() doesn't equal the logicalDpiY(), the corresponding QPaintEngine must handle the resolution mapping.

    See also physicalDpiX() and logicalDpiY().

    Look up this member in the source code.

    Toggle details int QPaintDevice

    widthwidth () ()const

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

    See also widthMM().

    Look up this member in the source code.

    Toggle details int QPaintDevice

    widthMMwidthMM () ()const

    Returns the width of the paint device in millimeters. Due to platform limitations it may not be possible to use this function to determine the actual physical size of a widget on the screen.

    See also width().

    Look up this member in the source code.

    Toggle details int QPaintDevice

    x11AppCellsx11AppCells ( int screen=-1 ) ( int screen=-1 ) [static] Qt3-support

    Use QX11Info::cells() instead.

    For example, if you have code like

    1. int cells = QPaintDevice::x11AppCells(screen);

    you can rewrite it as

    1. int cells = qApp->x11Info(screen).cells();

    See also QWidget::x11Info() and QPixmap::x11Info().

    Look up this member in the source code.

    Toggle details Qt::HANDLE QPaintDevice

    x11AppColormapx11AppColormap ( int screen=-1 ) ( int screen=-1 ) [static] Qt3-support

    Use QX11Info::colormap() instead.

    For example, if you have code like

    1. unsigned long colormap = QPaintDevice::x11AppColormap(screen);

    you can rewrite it as

    1. unsigned long colormap = qApp->x11Info(screen).colormap();

    See also QWidget::x11Info() and QPixmap::x11Info().

    Look up this member in the source code.

    Toggle details bool QPaintDevice

    x11AppDefaultColormapx11AppDefaultColormap ( int screen=-1 ) ( int screen=-1 ) [static] Qt3-support

    Use QX11Info::defaultColormap() instead.

    For example, if you have code like

    1. bool isDefault = QPaintDevice::x11AppDefaultColormap(screen);

    you can rewrite it as

    1. bool isDefault = qApp->x11Info(screen).defaultColormap();

    See also QWidget::x11Info() and QPixmap::x11Info().

    Look up this member in the source code.

    Toggle details bool QPaintDevice

    x11AppDefaultVisualx11AppDefaultVisual ( int screen=-1 ) ( int screen=-1 ) [static] Qt3-support

    Use QX11Info::defaultVisual() instead.

    For example, if you have code like

    1. bool isDefault = QPaintDevice::x11AppDefaultVisual(screen);

    you can rewrite it as

    1. bool isDefault = qApp->x11Info(screen).defaultVisual();

    See also QWidget::x11Info() and QPixmap::x11Info().

    Look up this member in the source code.

    Toggle details int QPaintDevice

    x11AppDepthx11AppDepth ( int screen=-1 ) ( int screen=-1 ) [static] Qt3-support

    Use QX11Info::depth() instead.

    For example, if you have code like

    1. int depth = QPaintDevice::x11AppDepth(screen);

    you can rewrite it as

    1. int depth = qApp->x11Info(screen).depth();

    See also QWidget::x11Info() and QPixmap::x11Info().

    Look up this member in the source code.

    Toggle details Display * QPaintDevice

    x11AppDisplayx11AppDisplay () () [static] Qt3-support

    Use QX11Info::display() instead.

    For example, if you have code like

    1. Display *display = QPaintDevice::x11AppDisplay();

    you can rewrite it as

    1. Display *display = qApp->x11Info().display();

    See also QWidget::x11Info() and QPixmap::x11Info().

    Look up this member in the source code.

    Toggle details int QPaintDevice

    x11AppDpiXx11AppDpiX ( int screen=-1 ) ( int screen=-1 ) [static] Qt3-support

    Use QX11Info::appDpiX() instead.

    For example, if you have code like

    1. bool isDefault = QPaintDevice::x11AppDpiX(screen);

    you can rewrite it as

    1. bool isDefault = qApp->x11Info(screen).appDpiX();

    See also QWidget::x11Info() and QPixmap::x11Info().

    Look up this member in the source code.

    Toggle details int QPaintDevice

    x11AppDpiYx11AppDpiY ( int screen=-1 ) ( int screen=-1 ) [static] Qt3-support

    Use QX11Info::appDpiY() instead.

    For example, if you have code like

    1. bool isDefault = QPaintDevice::x11AppDpiY(screen);

    you can rewrite it as

    1. bool isDefault = qApp->x11Info(screen).appDpiY();

    See also QWidget::x11Info() and QPixmap::x11Info().

    Look up this member in the source code.

    Toggle details Qt::HANDLE QPaintDevice

    x11AppRootWindowx11AppRootWindow ( int screen=-1 ) ( int screen=-1 ) [static] Qt3-support

    Use QX11Info::appRootWindow() instead.

    For example, if you have code like

    1. unsigned long window = QPaintDevice::x11AppRootWindow(screen);

    you can rewrite it as

    1. unsigned long window = qApp->x11Info(screen).appRootWindow();

    See also QWidget::x11Info() and QPixmap::x11Info().

    Look up this member in the source code.

    Toggle details int QPaintDevice

    x11AppScreenx11AppScreen () () [static] Qt3-support

    Use QX11Info::screen() instead.

    For example, if you have code like

    1. int screen = QPaintDevice::x11AppScreen();

    you can rewrite it as

    1. int screen = qApp->x11Info().screen();

    See also QWidget::x11Info() and QPixmap::x11Info().

    Look up this member in the source code.

    Toggle details void * QPaintDevice

    x11AppVisualx11AppVisual ( int screen=-1 ) ( int screen=-1 ) [static] Qt3-support

    Use QX11Info::visual() instead.

    For example, if you have code like

    1. void *visual = QPaintDevice::x11AppVisual(screen);

    you can rewrite it as

    1. void *visual = qApp->x11Info(screen).visual();

    See also QWidget::x11Info() and QPixmap::x11Info().

    Look up this member in the source code.

    Toggle details int QPaintDevice

    x11Cellsx11Cells () ()const Qt3-support

    Use QX11Info::cells() instead.

    For example, if you have code like

    1. int cells = widget->x11Cells();

    you can rewrite it as

    1. int cells = widget->x11Info().cells();

    See also QWidget::x11Info() and QPixmap::x11Info().

    Look up this member in the source code.

    Toggle details Qt::HANDLE QPaintDevice

    x11Colormapx11Colormap () ()const Qt3-support

    Use QX11Info::colormap() instead.

    For example, if you have code like

    1. unsigned long screen = widget->x11Colormap();

    you can rewrite it as

    1. unsigned long screen = widget->x11Info().colormap();

    See also QWidget::x11Info() and QPixmap::x11Info().

    Look up this member in the source code.

    Toggle details bool QPaintDevice

    x11DefaultColormapx11DefaultColormap () ()const Qt3-support

    Use QX11Info::defaultColormap() instead.

    For example, if you have code like

    1. bool isDefault = widget->x11DefaultColormap();

    you can rewrite it as

    1. bool isDefault = widget->x11Info().defaultColormap();

    See also QWidget::x11Info() and QPixmap::x11Info().

    Look up this member in the source code.

    Toggle details bool QPaintDevice

    x11DefaultVisualx11DefaultVisual () ()const Qt3-support

    Use QX11Info::defaultVisual() instead.

    For example, if you have code like

    1. bool isDefault = widget->x11DefaultVisual();

    you can rewrite it as

    1. bool isDefault = widget->x11Info().defaultVisual();

    See also QWidget::x11Info() and QPixmap::x11Info().

    Look up this member in the source code.

    Toggle details int QPaintDevice

    x11Depthx11Depth () ()const Qt3-support

    Use QX11Info::depth() instead.

    For example, if you have code like

    1. int depth = widget->x11Depth();

    you can rewrite it as

    1. int depth = widget->x11Info().depth();

    See also QWidget::x11Info() and QPixmap::x11Info().

    Look up this member in the source code.

    Toggle details Display * QPaintDevice

    x11Displayx11Display () ()const Qt3-support

    Use QX11Info::display() instead.

    For example, if you have code like

    1. Display *display = widget->x11Display();

    you can rewrite it as

    1. Display *display = QX11Info::display();

    See also QWidget::x11Info() and QX11Info::display().

    Look up this member in the source code.

    Toggle details int QPaintDevice

    x11Screenx11Screen () ()const Qt3-support

    Use QX11Info::screen() instead.

    For example, if you have code like

    1. int screen = widget->x11Screen();

    you can rewrite it as

    1. int screen = widget->x11Info().screen();

    See also QWidget::x11Info() and QPixmap::x11Info().

    Look up this member in the source code.

    Toggle details void QPaintDevice

    x11SetAppDpiXx11SetAppDpiX ( int dpi , int screen ) ( int dpi , int screen ) [static] Qt3-support

    Use QX11Info::setAppDpiX() instead.

    Look up this member in the source code.

    Toggle details void QPaintDevice

    x11SetAppDpiYx11SetAppDpiY ( int dpi , int screen ) ( int dpi , int screen ) [static] Qt3-support

    Use QX11Info::setAppDpiY() instead.

    Look up this member in the source code.

    Toggle details void * QPaintDevice

    x11Visualx11Visual () ()const Qt3-support

    Use QX11Info::visual() instead.

    For example, if you have code like

    1. void *visual = widget->x11Visual();

    you can rewrite it as

    1. void *visual = widget->x11Info().visual();

    See also QWidget::x11Info() and QPixmap::x11Info().

    Look up this member in the source code.

    Notes provided by the Qt Community

    No notes