The QPaintDevice 類是可以描繪對象的基類采用 QPainter . 更多...
| 頭: | #include <QPaintDevice> |
| qmake: | QT += gui |
| 繼承者: | QGLFramebufferObject , QGLPixelBuffer , QImage , QOpenGLPaintDevice , QPagedPaintDevice , QPaintDeviceWindow , QPicture , QPixmap , QSvgGenerator ,和 QWidget |
| enum | PaintDeviceMetric { PdmWidth, PdmHeight, PdmWidthMM, PdmHeightMM, ..., PdmDevicePixelRatioScaled } |
| virtual | ~QPaintDevice () |
| int | colorCount () const |
| int | depth () const |
| int | devicePixelRatio () const |
| qreal | devicePixelRatioF () 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 類是可以描繪對象的基類采用 QPainter .
描繪設備是 2D 空間的抽象,可以在其上繪製使用 QPainter 。它的默認坐標係原點位於左上角位置。X 嚮右遞增,Y 嚮下遞增。單位是 1 像素。
繪製能力對於 QPaintDevice 是目前實現的通過 QWidget , QImage , QPixmap , QGLPixelBuffer, QPicture ,和 QPrinter 子類。
要實現支持新後端,必須派生自 QPaintDevice 並重實現虛擬 paintEngine () 函數以告訴 QPainter 應使用哪種描繪引擎在此特定設備中繪製。注意,還必須創建相應描繪引擎纔能在設備中繪製,即:派生自 QPaintEngine 並重實現其虛函數。
警告: Qt 要求 QGuiApplication 對象就存在,在可以創建任何描繪設備之前。描繪設備會訪問窗口係統資源,且這些資源不會被初始化在創建應用程序對象之前。
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 (). |
QPaintDevice::PdmDevicePixelRatio
|
11
|
設備的設備像素比率。常見值 1 用於正常 DPI (每英寸點數) 顯示器,2 用於高 DPI 視網膜顯示器。 |
QPaintDevice::PdmDevicePixelRatioScaled
|
12
|
設備的比例縮放設備像素比率。這等同於 PdmDevicePixelRatio,除瞭值是按常量因子比例縮放以支持具有小數比例縮放因子的描繪設備。所用的常量比例縮放因子是 devicePixelRatioFScale()。該枚舉值在 Qt 5.6 引入。 |
另請參閱 metric () 和 devicePixelRatioF ().
[protected]
QPaintDevice::
QPaintDevice
()
構造描繪設備。此構造函數的援引隻可以從子類化的 QPaintDevice .
[虛擬]
QPaintDevice::
~QPaintDevice
()
銷毀描繪設備並釋放窗口係統資源。
返迴可用於描繪設備的不同顔色數。若要錶示的可用顔色數大於 int 數據類型,則返迴 INT_MAX 取而代之。
返迴描繪設備的位深度 (位平麵的數量)。
返迴用於設備的設備像素比率。
常見值為 1 對於普通 DPI (每英寸點數) 顯示,和為 2 對於高 DPI 視網膜顯示。
以浮點數形式返迴設備的設備像素比率。
該函數在 Qt 5.6 引入。
返迴描繪設備的高度,以默認坐標係單位為單位 (如:像素對於 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
返迴用於在設備上繪製的描繪引擎指針。
返迴
true
若設備目前正在其上描繪,即某人有調用
QPainter::begin
() 但尚未調用
QPainter::end
() 對於此設備;否則返迴
false
.
另請參閱 QPainter::isActive ().
返迴設備的水平分辨率,以 DPI (每英寸點數) 為單位。例如,當打印時,此分辨率是指物理打印機的分辨率。另一方麵,邏輯 DPI 是指實際描繪引擎使用的分辨率。
注意:若 physicalDpiX() 不等於 logicalDpiX (),相應 QPaintEngine 必須處理分辨率映射。
另請參閱 physicalDpiY () 和 logicalDpiX ().
返迴設備的水平分辨率,以 DPI (每英寸點數) 為單位。例如,當打印時,此分辨率是指物理打印機的分辨率。另一方麵,邏輯 DPI 是指實際描繪引擎使用的分辨率。
注意:若 physicalDpiY() 不等於 logicalDpiY (),相應 QPaintEngine 必須處理分辨率映射。
另請參閱 physicalDpiX () 和 logicalDpiY ().
返迴描繪設備的寬度,以默認坐標係單位為單位 (如:像素對於 QPixmap and QWidget ).
另請參閱 widthMM ().
返迴描繪設備的寬度,以毫米為單位。由於平颱局限性,可能無法使用此函數來確定屏幕中 Widget 的實際物理大小。
另請參閱 width ().