QPaintDeviceclass is the base class of objects that can be painted on withQPainter. 更多 …
继承者: QBitmap , QImage , QPagedPaintDevice , QPicture , QPixmap , QGLFramebufferObject , QGLPixelBuffer , QPrinter , QSvgGenerator
def
colorCount
()
def
depth
()
def
devicePixelRatio
()
def
devicePixelRatioF
()
def
height
()
def
heightMM
()
def
logicalDpiX
()
def
logicalDpiY
()
def
paintingActive
()
def
physicalDpiX
()
def
physicalDpiY
()
def
width
()
def
widthMM
()
def
devType
()
def
initPainter
(painter)
def
metric
(metric)
def
paintEngine
()
def
redirected
(offset)
def
sharedPainter
()
def
devicePixelRatioFScale
()
描绘设备是 2D 空间的抽象,可以在其上绘制使用
QPainter。它的默认坐标系统原点位于左上角位置。X 向右递增,Y 向下递增。单位是 1 像素。The drawing capabilities of
QPaintDeviceare currently implemented by theQWidget,QImage,QPixmap,QGLPixelBuffer,QPicture,和QPrinter子类。To implement support for a new backend, you must derive from
QPaintDeviceand reimplement the virtualpaintEngine()function to tellQPainterwhich 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 fromQPaintEngineand reimplement its virtual functions.警告
Qt requires that a
QGuiApplicationobject 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.
QPaintDeviceclass provides several functions returning the various device metrics: Thedepth()function returns its bit depth (number of bit planes). Theheight()function returns its height in default coordinate system units (e.g. pixels forQPixmapandQWidget) whileheightMM()returns the height of the device in millimeters. Similiarily, thewidth()andwidthMM()functions return the width of the device in default coordinate system units and in millimeters, respectively. Alternatively, the protectedmetric()function can be used to retrieve the metric information by specifying the desiredPaintDeviceMetric作为自变量。
logicalDpiX()andlogicalDpiY()functions return the horizontal and vertical resolution of the device in dots per inch. ThephysicalDpiX()andphysicalDpiY()functions also return the resolution of the device in dots per inch, but note that if the logical and physical resolution differ, the correspondingQPaintEnginemust handle the mapping. Finally, thecolorCount()function returns the number of different colors available for the paint device.另请参阅
QPaintDevice
¶
Constructs a paint device. This constructor can be invoked only from subclasses of
QPaintDevice
.
PySide2.QtGui.QPaintDevice.
PaintDeviceMetric
¶
描述描绘设备的各种指标。
|
常量 |
描述 |
|---|---|
|
QPaintDevice.PdmWidth |
The width of the paint device in default coordinate system units (e.g. pixels for
|
|
QPaintDevice.PdmHeight |
The height of the paint device in default coordinate system units (e.g. pixels for
|
|
QPaintDevice.PdmWidthMM |
描绘设备的宽度,以毫米为单位。另请参阅
|
|
QPaintDevice.PdmHeightMM |
描绘设备的高度,以毫米为单位。另请参阅
|
|
QPaintDevice.PdmNumColors |
The number of different colors available for the paint device. See also
|
|
QPaintDevice.PdmDepth |
The bit depth (number of bit planes) of the paint device. See also
|
|
QPaintDevice.PdmDpiX |
设备的水平分辨率 (以 DPI 每英寸点数为单位)。另请参阅
|
|
QPaintDevice.PdmDpiY |
设备的垂直分辨率 (以 DPI 每英寸点数为单位)。另请参阅
|
|
QPaintDevice.PdmPhysicalDpiX |
设备的水平分辨率 (以 DPI 每英寸点数为单位)。另请参阅
|
|
QPaintDevice.PdmPhysicalDpiY |
设备的垂直分辨率 (以 DPI 每英寸点数为单位)。另请参阅
|
|
QPaintDevice.PdmDevicePixelRatio |
The device pixel ratio for device. Common values are 1 for normal-dpi displays and 2 for high-dpi “retina” displays. |
|
QPaintDevice.PdmDevicePixelRatioScaled |
The scaled device pixel ratio for the device. This is identical to , except that the value is scaled by a constant factor in order to support paint devices with fractional scale factors. The constant scaling factor used is . This enum value has been introduced in Qt 5.6. |
PySide2.QtGui.QPaintDevice.
painters
¶
PySide2.QtGui.QPaintDevice.
colorCount
(
)
¶
int
Returns the number of different colors available for the paint device. If the number of colors available is too great to be represented by the int data type, then INT_MAX will be returned instead.
PySide2.QtGui.QPaintDevice.
depth
(
)
¶
int
返回描绘设备的位深度 (位平面的数量)。
PySide2.QtGui.QPaintDevice.
devType
(
)
¶
int
PySide2.QtGui.QPaintDevice.
devicePixelRatio
(
)
¶
int
返回设备的设备像素比率。
Common values are 1 for normal-dpi displays and 2 for high-dpi “retina” displays.
PySide2.QtGui.QPaintDevice.
devicePixelRatioF
(
)
¶
qreal
Returns the device pixel ratio for the device as a floating point number.
PySide2.QtGui.QPaintDevice.
devicePixelRatioFScale
(
)
¶
qreal
PySide2.QtGui.QPaintDevice.
height
(
)
¶
int
Returns the height of the paint device in default coordinate system units (e.g. pixels for
QPixmap
and
QWidget
).
另请参阅
PySide2.QtGui.QPaintDevice.
heightMM
(
)
¶
int
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.
另请参阅
PySide2.QtGui.QPaintDevice.
logicalDpiX
(
)
¶
int
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()
.
Note that if the doesn’t equal the
physicalDpiX()
, the corresponding
QPaintEngine
必须处理分辨率映射。
PySide2.QtGui.QPaintDevice.
logicalDpiY
(
)
¶
int
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()
.
Note that if the doesn’t equal the
physicalDpiY()
, the corresponding
QPaintEngine
必须处理分辨率映射。
PySide2.QtGui.QPaintDevice.
metric
(
metric
)
¶
metric
–
PaintDeviceMetric
int
Returns the metric information for the given paint device
metric
.
另请参阅
PaintDeviceMetric
PySide2.QtGui.QPaintDevice.
paintEngine
(
)
¶
返回用于在设备上绘制的描绘引擎指针。
PySide2.QtGui.QPaintDevice.
paintingActive
(
)
¶
bool
返回
true
if the device is currently being painted on, i.e. someone has called
begin()
but not yet called
end()
for this device; otherwise returns
false
.
另请参阅
PySide2.QtGui.QPaintDevice.
physicalDpiX
(
)
¶
int
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.
Note that if the doesn’t equal the
logicalDpiX()
, the corresponding
QPaintEngine
必须处理分辨率映射。
PySide2.QtGui.QPaintDevice.
physicalDpiY
(
)
¶
int
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.
Note that if the doesn’t equal the
logicalDpiY()
, the corresponding
QPaintEngine
必须处理分辨率映射。
PySide2.QtGui.QPaintDevice.
redirected
(
offset
)
¶
offset
–
QPoint