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 ().