
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQPaintDevice class is the base class of objects that can be painted.More...
| Header: | #include <QPaintDevice> |
| Inherited By: | QCustomRasterPaintDevice,QGLFramebufferObject,QGLPixelBuffer,QImage,QPicture,QPixmap,QPrinter,QSvgGenerator, andQWidget |
| enum | PaintDeviceMetric { PdmWidth, PdmHeight, PdmWidthMM, PdmHeightMM, ..., PdmPhysicalDpiY } |
| virtual | ~QPaintDevice() |
| int | colorCount() const |
| int | depth() const |
| int | height() const |
| int | heightMM() const |
| int | logicalDpiX() const |
| int | logicalDpiY() const |
| virtual QPaintEngine * | paintEngine() const = 0 |
| bool | paintingActive() const |
| int | physicalDpiX() const |
| int | physicalDpiY() const |
| int | width() const |
| int | widthMM() const |
| QPaintDevice() | |
| virtual int | metric(PaintDeviceMetric metric) const |
TheQPaintDevice 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 aQPainter. 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 ofQPaintDevice are currently implemented by theQWidget,QImage,QPixmap,QGLPixelBuffer,QPicture, andQPrinter subclasses.
To implement support for a new backend, you must derive fromQPaintDevice and reimplement the virtualpaintEngine() function to tellQPainter 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 fromQPaintEngine and reimplement its virtual functions.
Warning: Qt requires that aQApplication 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.
TheQPaintDevice class provides several functions returning the various device metrics: Thedepth() function returns its bit depth (number of bit planes). Theheight() function returns its height in default coordinate system units (e.g. pixels forQPixmap andQWidget) whileheightMM() returns the height of the device in millimeters. Similiarily, thewidth() andwidthMM() functions return the width of the device in default coordinate system units and in millimeters, respectively. Alternatively, the protectedmetric() function can be used to retrieve the metric information by specifying the desiredPaintDeviceMetric as argument.
ThelogicalDpiX() andlogicalDpiY() functions return the horizontal and vertical resolution of the device in dots per inch. ThephysicalDpiX() andphysicalDpiY() functions also return the resolution of the device in dots per inch, but note that if the logical and physical resolution differ, the correspondingQPaintEngine must handle the mapping. Finally, thecolorCount() function returns the number of different colors available for the paint device.
See alsoQPaintEngine,QPainter,Coordinate System, andPaint System.
Describes the various metrics of a paint device.
| Constant | Value | Description |
|---|---|---|
QPaintDevice::PdmWidth | 1 | The width of the paint device in default coordinate system units (e.g. pixels forQPixmap andQWidget). See alsowidth(). |
QPaintDevice::PdmHeight | 2 | The height of the paint device in default coordinate system units (e.g. pixels forQPixmap andQWidget). See alsoheight(). |
QPaintDevice::PdmWidthMM | 3 | The width of the paint device in millimeters. See alsowidthMM(). |
QPaintDevice::PdmHeightMM | 4 | The height of the paint device in millimeters. See alsoheightMM(). |
QPaintDevice::PdmNumColors | 5 | The number of different colors available for the paint device. See alsocolorCount(). |
QPaintDevice::PdmDepth | 6 | The bit depth (number of bit planes) of the paint device. See alsodepth(). |
QPaintDevice::PdmDpiX | 7 | The horizontal resolution of the device in dots per inch. See alsologicalDpiX(). |
QPaintDevice::PdmDpiY | 8 | The vertical resolution of the device in dots per inch. See alsologicalDpiY(). |
QPaintDevice::PdmPhysicalDpiX | 9 | The horizontal resolution of the device in dots per inch. See alsophysicalDpiX(). |
QPaintDevice::PdmPhysicalDpiY | 10 | The vertical resolution of the device in dots per inch. See alsophysicalDpiY(). |
See alsometric().
[protected]QPaintDevice::QPaintDevice()Constructs a paint device. This constructor can be invoked only from subclasses ofQPaintDevice.
[virtual]QPaintDevice::~QPaintDevice()Destroys the paint device and frees window system resources.
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.
Returns the bit depth (number of bit planes) of the paint device.
Returns the height of the paint device in default coordinate system units (e.g. pixels forQPixmap andQWidget).
See alsoheightMM().
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 alsoheight().
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 fromwidthMM().
Note that if the logicalDpiX() doesn't equal thephysicalDpiX(), the correspondingQPaintEngine must handle the resolution mapping.
See alsologicalDpiY() andphysicalDpiX().
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 fromheightMM().
Note that if the logicalDpiY() doesn't equal thephysicalDpiY(), the correspondingQPaintEngine must handle the resolution mapping.
See alsologicalDpiX() andphysicalDpiY().
[virtual protected]int QPaintDevice::metric(PaintDeviceMetric metric) constReturns the metric information for the given paint devicemetric.
See alsoPaintDeviceMetric.
[pure virtual]QPaintEngine * QPaintDevice::paintEngine() constReturns a pointer to the paint engine used for drawing on the device.
Returns true if the device is currently being painted on, i.e. someone has calledQPainter::begin() but not yet calledQPainter::end() for this device; otherwise returns false.
See alsoQPainter::isActive().
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 thelogicalDpiX(), the correspondingQPaintEngine must handle the resolution mapping.
See alsophysicalDpiY() andlogicalDpiX().
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 thelogicalDpiY(), the correspondingQPaintEngine must handle the resolution mapping.
See alsophysicalDpiX() andlogicalDpiY().
Returns the width of the paint device in default coordinate system units (e.g. pixels forQPixmap andQWidget).
See alsowidthMM().
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 alsowidth().
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.