Struct qt_gui::QPaintDevice
source · #[repr(C)]pub struct QPaintDevice { /* private fields */ }
Expand description
The QPaintDevice class is the base class of objects that can be painted on with QPainter.
C++ class: QPaintDevice
.
The QPaintDevice class is the base class of objects that can be painted on with QPainter.
A paint device is an abstraction of a two-dimensional space that can be drawn on 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, and QPrinter subclasses.
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 functions.
Warning: Qt requires that a QGuiApplication 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() returns the height of the device in millimeters. Similiarily, the width() and 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 argument.
The logicalDpiX() and logicalDpiY() functions return the horizontal and vertical resolution of the device in dots per inch. The physicalDpiX() and 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() function returns the number of different colors available for the paint device.
Implementations§
source§impl QPaintDevice
impl QPaintDevice
sourcepub unsafe fn color_count(&self) -> c_int
pub unsafe fn color_count(&self) -> c_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.
Calls C++ function: int QPaintDevice::colorCount() const
.
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.
sourcepub unsafe fn depth(&self) -> c_int
pub unsafe fn depth(&self) -> c_int
Returns the bit depth (number of bit planes) of the paint device.
Calls C++ function: int QPaintDevice::depth() const
.
Returns the bit depth (number of bit planes) of the paint device.
sourcepub unsafe fn dev_type(&self) -> c_int
pub unsafe fn dev_type(&self) -> c_int
Calls C++ function: virtual int QPaintDevice::devType() const
.
sourcepub unsafe fn device_pixel_ratio(&self) -> c_int
pub unsafe fn device_pixel_ratio(&self) -> c_int
Returns the device pixel ratio for device.
Calls C++ function: int QPaintDevice::devicePixelRatio() const
.
Returns the device pixel ratio for device.
Common values are 1 for normal-dpi displays and 2 for high-dpi "retina" displays.
sourcepub unsafe fn device_pixel_ratio_f(&self) -> c_double
pub unsafe fn device_pixel_ratio_f(&self) -> c_double
Returns the device pixel ratio for the device as a floating point number.
Calls C++ function: double QPaintDevice::devicePixelRatioF() const
.
Returns the device pixel ratio for the device as a floating point number.
This function was introduced in Qt 5.6.
sourcepub unsafe fn device_pixel_ratio_f_scale() -> c_double
pub unsafe fn device_pixel_ratio_f_scale() -> c_double
Calls C++ function: static double QPaintDevice::devicePixelRatioFScale()
.
sourcepub unsafe fn height(&self) -> c_int
pub unsafe fn height(&self) -> c_int
sourcepub unsafe fn height_m_m(&self) -> c_int
pub unsafe fn height_m_m(&self) -> c_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.
Calls C++ function: int QPaintDevice::heightMM() const
.
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.
See also height().
sourcepub unsafe fn logical_dpi_x(&self) -> c_int
pub unsafe fn logical_dpi_x(&self) -> c_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().
Calls C++ function: int QPaintDevice::logicalDpiX() const
.
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 logicalDpiX() doesn't equal the physicalDpiX(), the corresponding QPaintEngine must handle the resolution mapping.
See also logicalDpiY() and physicalDpiX().
sourcepub unsafe fn logical_dpi_y(&self) -> c_int
pub unsafe fn logical_dpi_y(&self) -> c_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().
Calls C++ function: int QPaintDevice::logicalDpiY() const
.
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 logicalDpiY() doesn't equal the physicalDpiY(), the corresponding QPaintEngine must handle the resolution mapping.
See also logicalDpiX() and physicalDpiY().
sourcepub unsafe fn paint_engine(&self) -> Ptr<QPaintEngine>
pub unsafe fn paint_engine(&self) -> Ptr<QPaintEngine>
Returns a pointer to the paint engine used for drawing on the device.
Calls C++ function: pure virtual QPaintEngine* QPaintDevice::paintEngine() const
.
Returns a pointer to the paint engine used for drawing on the device.
sourcepub unsafe fn painting_active(&self) -> bool
pub unsafe fn painting_active(&self) -> bool
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
.
Calls C++ function: bool QPaintDevice::paintingActive() const
.
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
.
See also QPainter::isActive().
sourcepub unsafe fn physical_dpi_x(&self) -> c_int
pub unsafe fn physical_dpi_x(&self) -> c_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.
Calls C++ function: int QPaintDevice::physicalDpiX() const
.
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 physicalDpiX() doesn't equal the logicalDpiX(), the corresponding QPaintEngine must handle the resolution mapping.
See also physicalDpiY() and logicalDpiX().
sourcepub unsafe fn physical_dpi_y(&self) -> c_int
pub unsafe fn physical_dpi_y(&self) -> c_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.
Calls C++ function: int QPaintDevice::physicalDpiY() const
.
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 physicalDpiY() doesn't equal the logicalDpiY(), the corresponding QPaintEngine must handle the resolution mapping.
See also physicalDpiX() and logicalDpiY().
sourcepub unsafe fn width(&self) -> c_int
pub unsafe fn width(&self) -> c_int
sourcepub unsafe fn width_m_m(&self) -> c_int
pub unsafe fn width_m_m(&self) -> c_int
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.
Calls C++ function: int QPaintDevice::widthMM() const
.
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.
See also width().
Trait Implementations§
source§impl CppDeletable for QPaintDevice
impl CppDeletable for QPaintDevice
source§impl DynamicCast<QBitmap> for QPaintDevice
impl DynamicCast<QBitmap> for QPaintDevice
source§unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QBitmap>
unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QBitmap>
Calls C++ function: QBitmap* dynamic_cast<QBitmap*>(QPaintDevice* ptr)
.
source§impl DynamicCast<QImage> for QPaintDevice
impl DynamicCast<QImage> for QPaintDevice
source§unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QImage>
unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QImage>
Calls C++ function: QImage* dynamic_cast<QImage*>(QPaintDevice* ptr)
.
source§impl DynamicCast<QOpenGLPaintDevice> for QPaintDevice
impl DynamicCast<QOpenGLPaintDevice> for QPaintDevice
source§unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QOpenGLPaintDevice>
unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QOpenGLPaintDevice>
Calls C++ function: QOpenGLPaintDevice* dynamic_cast<QOpenGLPaintDevice*>(QPaintDevice* ptr)
.
source§impl DynamicCast<QOpenGLWindow> for QPaintDevice
impl DynamicCast<QOpenGLWindow> for QPaintDevice
source§unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QOpenGLWindow>
unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QOpenGLWindow>
Calls C++ function: QOpenGLWindow* dynamic_cast<QOpenGLWindow*>(QPaintDevice* ptr)
.
source§impl DynamicCast<QPagedPaintDevice> for QPaintDevice
impl DynamicCast<QPagedPaintDevice> for QPaintDevice
source§unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QPagedPaintDevice>
unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QPagedPaintDevice>
Calls C++ function: QPagedPaintDevice* dynamic_cast<QPagedPaintDevice*>(QPaintDevice* ptr)
.
source§impl DynamicCast<QPaintDeviceWindow> for QPaintDevice
impl DynamicCast<QPaintDeviceWindow> for QPaintDevice
source§unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QPaintDeviceWindow>
unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QPaintDeviceWindow>
Calls C++ function: QPaintDeviceWindow* dynamic_cast<QPaintDeviceWindow*>(QPaintDevice* ptr)
.
source§impl DynamicCast<QPdfWriter> for QPaintDevice
impl DynamicCast<QPdfWriter> for QPaintDevice
source§unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QPdfWriter>
unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QPdfWriter>
Calls C++ function: QPdfWriter* dynamic_cast<QPdfWriter*>(QPaintDevice* ptr)
.
source§impl DynamicCast<QPicture> for QPaintDevice
impl DynamicCast<QPicture> for QPaintDevice
source§unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QPicture>
unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QPicture>
Calls C++ function: QPicture* dynamic_cast<QPicture*>(QPaintDevice* ptr)
.
source§impl DynamicCast<QPixmap> for QPaintDevice
impl DynamicCast<QPixmap> for QPaintDevice
source§unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QPixmap>
unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QPixmap>
Calls C++ function: QPixmap* dynamic_cast<QPixmap*>(QPaintDevice* ptr)
.
source§impl DynamicCast<QRasterWindow> for QPaintDevice
impl DynamicCast<QRasterWindow> for QPaintDevice
source§unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QRasterWindow>
unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QRasterWindow>
Calls C++ function: QRasterWindow* dynamic_cast<QRasterWindow*>(QPaintDevice* ptr)
.
source§impl StaticDowncast<QBitmap> for QPaintDevice
impl StaticDowncast<QBitmap> for QPaintDevice
source§unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QBitmap>
unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QBitmap>
Calls C++ function: QBitmap* static_cast<QBitmap*>(QPaintDevice* ptr)
.
source§impl StaticDowncast<QImage> for QPaintDevice
impl StaticDowncast<QImage> for QPaintDevice
source§unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QImage>
unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QImage>
Calls C++ function: QImage* static_cast<QImage*>(QPaintDevice* ptr)
.
source§impl StaticDowncast<QOpenGLPaintDevice> for QPaintDevice
impl StaticDowncast<QOpenGLPaintDevice> for QPaintDevice
source§unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QOpenGLPaintDevice>
unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QOpenGLPaintDevice>
Calls C++ function: QOpenGLPaintDevice* static_cast<QOpenGLPaintDevice*>(QPaintDevice* ptr)
.
source§impl StaticDowncast<QOpenGLWindow> for QPaintDevice
impl StaticDowncast<QOpenGLWindow> for QPaintDevice
source§unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QOpenGLWindow>
unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QOpenGLWindow>
Calls C++ function: QOpenGLWindow* static_cast<QOpenGLWindow*>(QPaintDevice* ptr)
.
source§impl StaticDowncast<QPagedPaintDevice> for QPaintDevice
impl StaticDowncast<QPagedPaintDevice> for QPaintDevice
source§unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QPagedPaintDevice>
unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QPagedPaintDevice>
Calls C++ function: QPagedPaintDevice* static_cast<QPagedPaintDevice*>(QPaintDevice* ptr)
.
source§impl StaticDowncast<QPaintDeviceWindow> for QPaintDevice
impl StaticDowncast<QPaintDeviceWindow> for QPaintDevice
source§unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QPaintDeviceWindow>
unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QPaintDeviceWindow>
Calls C++ function: QPaintDeviceWindow* static_cast<QPaintDeviceWindow*>(QPaintDevice* ptr)
.
source§impl StaticDowncast<QPdfWriter> for QPaintDevice
impl StaticDowncast<QPdfWriter> for QPaintDevice
source§unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QPdfWriter>
unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QPdfWriter>
Calls C++ function: QPdfWriter* static_cast<QPdfWriter*>(QPaintDevice* ptr)
.
source§impl StaticDowncast<QPicture> for QPaintDevice
impl StaticDowncast<QPicture> for QPaintDevice
source§unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QPicture>
unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QPicture>
Calls C++ function: QPicture* static_cast<QPicture*>(QPaintDevice* ptr)
.
source§impl StaticDowncast<QPixmap> for QPaintDevice
impl StaticDowncast<QPixmap> for QPaintDevice
source§unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QPixmap>
unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QPixmap>
Calls C++ function: QPixmap* static_cast<QPixmap*>(QPaintDevice* ptr)
.
source§impl StaticDowncast<QRasterWindow> for QPaintDevice
impl StaticDowncast<QRasterWindow> for QPaintDevice
source§unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QRasterWindow>
unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QRasterWindow>
Calls C++ function: QRasterWindow* static_cast<QRasterWindow*>(QPaintDevice* ptr)
.
source§impl StaticUpcast<QPaintDevice> for QBitmap
impl StaticUpcast<QPaintDevice> for QBitmap
source§unsafe fn static_upcast(ptr: Ptr<QBitmap>) -> Ptr<QPaintDevice>
unsafe fn static_upcast(ptr: Ptr<QBitmap>) -> Ptr<QPaintDevice>
Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QBitmap* ptr)
.
source§impl StaticUpcast<QPaintDevice> for QImage
impl StaticUpcast<QPaintDevice> for QImage
source§unsafe fn static_upcast(ptr: Ptr<QImage>) -> Ptr<QPaintDevice>
unsafe fn static_upcast(ptr: Ptr<QImage>) -> Ptr<QPaintDevice>
Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QImage* ptr)
.
source§impl StaticUpcast<QPaintDevice> for QOpenGLPaintDevice
impl StaticUpcast<QPaintDevice> for QOpenGLPaintDevice
source§unsafe fn static_upcast(ptr: Ptr<QOpenGLPaintDevice>) -> Ptr<QPaintDevice>
unsafe fn static_upcast(ptr: Ptr<QOpenGLPaintDevice>) -> Ptr<QPaintDevice>
Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QOpenGLPaintDevice* ptr)
.
source§impl StaticUpcast<QPaintDevice> for QOpenGLWindow
impl StaticUpcast<QPaintDevice> for QOpenGLWindow
source§unsafe fn static_upcast(ptr: Ptr<QOpenGLWindow>) -> Ptr<QPaintDevice>
unsafe fn static_upcast(ptr: Ptr<QOpenGLWindow>) -> Ptr<QPaintDevice>
Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QOpenGLWindow* ptr)
.
source§impl StaticUpcast<QPaintDevice> for QPagedPaintDevice
impl StaticUpcast<QPaintDevice> for QPagedPaintDevice
source§unsafe fn static_upcast(ptr: Ptr<QPagedPaintDevice>) -> Ptr<QPaintDevice>
unsafe fn static_upcast(ptr: Ptr<QPagedPaintDevice>) -> Ptr<QPaintDevice>
Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QPagedPaintDevice* ptr)
.
source§impl StaticUpcast<QPaintDevice> for QPaintDeviceWindow
impl StaticUpcast<QPaintDevice> for QPaintDeviceWindow
source§unsafe fn static_upcast(ptr: Ptr<QPaintDeviceWindow>) -> Ptr<QPaintDevice>
unsafe fn static_upcast(ptr: Ptr<QPaintDeviceWindow>) -> Ptr<QPaintDevice>
Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QPaintDeviceWindow* ptr)
.
source§impl StaticUpcast<QPaintDevice> for QPdfWriter
impl StaticUpcast<QPaintDevice> for QPdfWriter
source§unsafe fn static_upcast(ptr: Ptr<QPdfWriter>) -> Ptr<QPaintDevice>
unsafe fn static_upcast(ptr: Ptr<QPdfWriter>) -> Ptr<QPaintDevice>
Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QPdfWriter* ptr)
.
source§impl StaticUpcast<QPaintDevice> for QPicture
impl StaticUpcast<QPaintDevice> for QPicture
source§unsafe fn static_upcast(ptr: Ptr<QPicture>) -> Ptr<QPaintDevice>
unsafe fn static_upcast(ptr: Ptr<QPicture>) -> Ptr<QPaintDevice>
Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QPicture* ptr)
.
source§impl StaticUpcast<QPaintDevice> for QPixmap
impl StaticUpcast<QPaintDevice> for QPixmap
source§unsafe fn static_upcast(ptr: Ptr<QPixmap>) -> Ptr<QPaintDevice>
unsafe fn static_upcast(ptr: Ptr<QPixmap>) -> Ptr<QPaintDevice>
Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QPixmap* ptr)
.
source§impl StaticUpcast<QPaintDevice> for QRasterWindow
impl StaticUpcast<QPaintDevice> for QRasterWindow
source§unsafe fn static_upcast(ptr: Ptr<QRasterWindow>) -> Ptr<QPaintDevice>
unsafe fn static_upcast(ptr: Ptr<QRasterWindow>) -> Ptr<QPaintDevice>
Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QRasterWindow* ptr)
.