The QPaintDevice class is the base class of objects that can be painted. 更多...
| 头: | #include <QPaintDevice> |
| 继承者: | QCustomRasterPaintDevice , QGLFramebufferObject , QGLPixelBuffer , QImage , QPicture , QPixmap , QPrinter , QSvgGenerator ,和 QWidget |
| 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 |
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 。它的默认坐标系原点位于左上角位置。X 向右递增,Y 向下递增。单位是 1 像素。
绘制能力对于 QPaintDevice 是目前实现的通过 QWidget , QImage , QPixmap , QGLPixelBuffer , QPicture ,和 QPrinter 子类。
要实现支持新后端,必须派生自 QPaintDevice 并重实现虚拟 paintEngine () 函数以告诉 QPainter 应使用哪种描绘引擎在此特定设备中绘制。注意,还必须创建相应描绘引擎才能在设备中绘制,即:派生自 QPaintEngine 并重实现其虚函数。
警告: Qt 要求 QApplication 对象就存在,在可以创建任何描绘设备之前。描绘设备会访问窗口系统资源,且这些资源不会被初始化在创建应用程序对象之前。
The QPaintDevice 类提供了返回各种设备指标的几个函数: depth () 函数返回其位深度 (位平面的数量)。 height () 函数以默认坐标系单位返回其高度 (如像素对于 QPixmap and QWidget ) 而 heightMM () 返回设备的高度 (以毫米为单位)。同样, width () 和 widthMM () 函数分别以默认坐标系单位和以毫米为单位返回设备的宽度。另外,受保护的 metric () 函数可以用于检索指标信息通过指定期望的 PaintDeviceMetric 作为自变量。
The logicalDpiX () 和 logicalDpiY () 函数以 DPI (每英寸点数) 为单位返回设备的水平和垂直分辨率。 physicalDpiX () 和 physicalDpiY () 函数还以 DPI (每英寸点数) 为单位返回设备的分辨率,请注意,若逻辑分辨率和物理分辨率不同,相应 QPaintEngine 必须处理映射。最后, colorCount () 函数返回可用于描绘设备的不同颜色的数量。
另请参阅 QPaintEngine , QPainter , 坐标系 ,和 描绘系统 .
描述描绘设备的各种指标。
| 常量 | 值 | 描述 |
|---|---|---|
QPaintDevice::PdmWidth
|
1
|
以默认坐标系单位描绘设备的宽度 (如像素对于 QPixmap and QWidget )。另请参阅 width (). |
QPaintDevice::PdmHeight
|
2
|
以默认坐标系单位描绘设备的高度 (如像素对于 QPixmap and QWidget )。另请参阅 height (). |
QPaintDevice::PdmWidthMM
|
3
|
描绘设备的宽度,以毫米为单位。另请参阅 widthMM (). |
QPaintDevice::PdmHeightMM
|
4
|
描绘设备的高度,以毫米为单位。另请参阅 heightMM (). |
QPaintDevice::PdmNumColors
|
5
|
可用于描绘设备的不同颜色的数量。另请参阅 colorCount (). |
QPaintDevice::PdmDepth
|
6
|
描绘设备的位深度 (位平面的数量)。另请参阅 depth (). |
QPaintDevice::PdmDpiX
|
7
|
设备的水平分辨率 (以 DPI 每英寸点数为单位)。另请参阅 logicalDpiX (). |
QPaintDevice::PdmDpiY
|
8
|
设备的垂直分辨率 (以 DPI 每英寸点数为单位)。另请参阅 logicalDpiY (). |
QPaintDevice::PdmPhysicalDpiX
|
9
|
设备的水平分辨率 (以 DPI 每英寸点数为单位)。另请参阅 physicalDpiX (). |
QPaintDevice::PdmPhysicalDpiY
|
10
|
设备的垂直分辨率 (以 DPI 每英寸点数为单位)。另请参阅 physicalDpiY (). |
另请参阅 metric ().
[protected]
QPaintDevice::
QPaintDevice
()
构造描绘设备。此构造函数的援引只可以从子类化的 QPaintDevice .
[虚拟]
QPaintDevice::
~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.
返回描绘设备的位深度 (位平面的数量)。
返回描绘设备的高度,以默认坐标系单位为单位 (如:像素对于 QPixmap and QWidget ).
另请参阅 heightMM ().
返回描绘设备的高度,以毫米为单位。由于平台局限性,可能无法使用此函数来确定屏幕中 Widget 的实际物理大小。
另请参阅 height ().
返回设备的水平分辨率以 DPI (每英寸点数) 为单位,用于计算字体大小。对于 X11,这通常如同计算从 widthMM ().
注意:若 logicalDpiX() 不等于 physicalDpiX (),相应 QPaintEngine 必须处理分辨率映射。
另请参阅 logicalDpiY () 和 physicalDpiX ().
返回设备的垂直分辨率以 DPI (每英寸点数) 为单位,用于计算字体大小。对于 X11,这通常如同计算从 heightMM ().
注意:若 logicalDpiY() 不等于 physicalDpiY (),相应 QPaintEngine 必须处理分辨率映射。
另请参阅 logicalDpiX () 和 physicalDpiY ().
[virtual protected]
int
QPaintDevice::
metric
(
PaintDeviceMetric
metric
) const
返回规格信息为给定描绘设备 metric .
另请参阅 PaintDeviceMetric .
[pure virtual]
QPaintEngine
* QPaintDevice::
paintEngine
() const
返回用于在设备上绘制的描绘引擎指针。
Returns true if the device is currently being painted on, i.e. someone has called QPainter::begin () 但尚未调用 QPainter::end () for this device; otherwise returns false.
另请参阅 QPainter::isActive ().
返回设备的水平分辨率,以 DPI (每英寸点数) 为单位。例如,当打印时,此分辨率是指物理打印机的分辨率。另一方面,逻辑 DPI 是指实际描绘引擎使用的分辨率。
注意:若 physicalDpiX() 不等于 logicalDpiX (),相应 QPaintEngine 必须处理分辨率映射。
另请参阅 physicalDpiY () 和 logicalDpiX ().
返回设备的水平分辨率,以 DPI (每英寸点数) 为单位。例如,当打印时,此分辨率是指物理打印机的分辨率。另一方面,逻辑 DPI 是指实际描绘引擎使用的分辨率。
注意:若 physicalDpiY() 不等于 logicalDpiY (),相应 QPaintEngine 必须处理分辨率映射。
另请参阅 physicalDpiX () 和 logicalDpiY ().
返回描绘设备的宽度,以默认坐标系单位为单位 (如:像素对于 QPixmap and QWidget ).
另请参阅 widthMM ().
返回描绘设备的宽度,以毫米为单位。由于平台局限性,可能无法使用此函数来确定屏幕中 Widget 的实际物理大小。
另请参阅 width ().