QPaintDevice Class
The QPaintDevice class is the base class of objects that QPainter can paint on. More…
| Header | #include <QPaintDevice> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Gui) |
| Module | Nt GUI C++ Classes |
| Inherited by | QImage, QOpenGLPaintDevice, QPaintDeviceWindow, QPixmap, QSvgGenerator, QWidget |
List of all members, including inherited members
Public Types
Public Functions
| virtual | ~QPaintDevice() |
| virtual QPaintEngine * | paintEngine() const |
| int | width() const |
| int | height() const |
| int | widthMM() const |
| int | heightMM() const |
| int | colorCount() const |
| int | depth() const |
| int | logicalDpiX() const |
| int | logicalDpiY() const |
| qreal | devicePixelRatio() const |
| bool | paintingActive() const |
Protected Functions
| QPaintDevice() | |
| virtual int | metric(PaintDeviceMetric metric) const |
| virtual QPaintDevice * | redirected(QPoint *offset) const |
| virtual bool | systemClip(QRegion *region) const |
Detailed Description
A paint device is a surface with a width, a height and a paint engine. QImage and the windows of Nt GUI are paint devices.
See also QPainter, QPaintEngine and QImage.
Differences from Qt
The device pixel ratio is always 1, and there is no colorCount() other than 16777216. The paint device does not need to be a QImage-sized object: any class that returns a paint engine can serve.
Member Type Documentation
enum QPaintDevice::PaintDeviceMetric
This enum describes the metrics that a paint device can report.
| Constant | Description |
|---|---|
QPaintDevice::PdmWidth | The width in pixels. |
QPaintDevice::PdmHeight | The height in pixels. |
QPaintDevice::PdmWidthMM | The width in millimeters. |
QPaintDevice::PdmHeightMM | The height in millimeters. |
QPaintDevice::PdmNumColors | The number of colors. |
QPaintDevice::PdmDepth | The bit depth of a pixel. |
QPaintDevice::PdmDpiX | The horizontal resolution in dots per inch. |
QPaintDevice::PdmDpiY | The vertical resolution in dots per inch. |
QPaintDevice::PdmDevicePixelRatio | The device pixel ratio, rounded down. |
QPaintDevice::PdmDevicePixelRatioScaled | The device pixel ratio multiplied by 65536. |
Member Function Documentation
QPaintDevice::QPaintDevice()
Constructs a paint device.
QPaintDevice::~QPaintDevice()
Destroys the paint device.
int QPaintDevice::colorCount() const
Returns the number of colors the device supports.
int QPaintDevice::depth() const
Returns the number of bits per pixel.
qreal QPaintDevice::devicePixelRatio() const
Returns the number of device pixels that a unit of the device's coordinates stands for: 1 on an ordinary device and 2 on a high-resolution screen at twice the usual density. A QPainter scales what it draws by this factor.
int QPaintDevice::height() const
Returns the height of the device in pixels.
int QPaintDevice::heightMM() const
Returns the height of the device in millimeters.
int QPaintDevice::logicalDpiX() const
Returns the horizontal resolution in dots per inch.
int QPaintDevice::logicalDpiY() const
Returns the vertical resolution in dots per inch.
int QPaintDevice::metric(PaintDeviceMetric metric) const
Returns the value of metric. The default implementation reports a screen of 96 dots per inch and 32 bits per pixel, and 0 for the sizes.
QPaintEngine * QPaintDevice::paintEngine() const
Returns the paint engine that paints on this device. A painter calls it when painting begins. The device owns the engine.
bool QPaintDevice::paintingActive() const
Returns true if a QPainter is painting on the device.
QPaintDevice * QPaintDevice::redirected(QPoint *offset) const
Returns the device that this device paints on, or nullptr if it paints on itself. A painter that begins on this device paints on the returned device instead, and the position of this device in it is added to offset. The default returns nullptr.
bool QPaintDevice::systemClip(QRegion *region) const
Returns true if painting on this device is restricted to a part of the device it is redirected to, and stores that part in region, in the coordinates of that device. A widget returns the part of its window that is visible and being painted. The default returns false.
See also redirected().
int QPaintDevice::width() const
Returns the width of the device in pixels.
int QPaintDevice::widthMM() const
Returns the width of the device in millimeters.