The QPaintDevice class is the base class of objects that can be painted. 更多...
Inherited by QGLFramebufferObject , QGLPixelBuffer , QImage , QPicture , QPixmap , QPrinter , QSvgGenerator and QWidget .
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 ,和 QPrinter 子类。
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 函数。
警告: 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 () 返回 the height of the device in millimeters. Similiarily, the width () 和 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 自变量。
logicalDpiX () and logicalDpiY () functions return the horizontal and vertical resolution of the device in dots per inch. The physicalDpiX () 和 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 () 函数返回 the number of different colors available for the paint device.
描述描绘设备的各种指标。
| 常量 | 值 | 描述 |
|---|---|---|
| QPaintDevice.PdmWidth | 1 | The width of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget ). 另请参阅 width (). |
| QPaintDevice.PdmHeight | 2 | The height of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget ). 另请参阅 height (). |
| QPaintDevice.PdmWidthMM | 3 | The width of the paint device in millimeters. 另请参阅 widthMM (). |
| QPaintDevice.PdmHeightMM | 4 | The height of the paint device in millimeters. 另请参阅 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 (). |
另请参阅 metric ().
Constructs a paint device. This constructor can be invoked only from subclasses of QPaintDevice .
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 设备。
Returns the height of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget ).
另请参阅 heightMM ().
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.
另请参阅 height ().
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 ().
注意:若 logicalDpiX() 不等于 physicalDpiX (), the corresponding QPaintEngine must handle the resolution mapping.
另请参阅 logicalDpiY () 和 physicalDpiX ().
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 ().
注意:若 logicalDpiY() 不等于 physicalDpiY (), the corresponding QPaintEngine must handle the resolution mapping.
另请参阅 logicalDpiX () 和 physicalDpiY ().
Returns the metric information for the given paint device metric .
另请参阅 PaintDeviceMetric .
此函数被弃用。
使用 colorCount () 代替。
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.
This method is abstract and should be reimplemented in any sub-class.
Returns a pointer to the paint engine used for drawing on the 设备。
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.
另请参阅 QPainter.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.
注意:若 physicalDpiX() 不等于 logicalDpiX (), the corresponding QPaintEngine must handle the resolution mapping.
另请参阅 physicalDpiY () 和 logicalDpiX ().
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.
注意:若 physicalDpiY() 不等于 logicalDpiY (), the corresponding QPaintEngine must handle the resolution mapping.
另请参阅 physicalDpiX () 和 logicalDpiY ().
Returns the width of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget ).
另请参阅 widthMM ().
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.
另请参阅 width ().