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.

C++ documentation:

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

source

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.

C++ documentation:

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.

source

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.

C++ documentation:

Returns the bit depth (number of bit planes) of the paint device.

source

pub unsafe fn dev_type(&self) -> c_int

Calls C++ function: virtual int QPaintDevice::devType() const.

source

pub unsafe fn device_pixel_ratio(&self) -> c_int

Returns the device pixel ratio for device.

Calls C++ function: int QPaintDevice::devicePixelRatio() const.

C++ documentation:

Returns the device pixel ratio for device.

Common values are 1 for normal-dpi displays and 2 for high-dpi "retina" displays.

source

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.

C++ documentation:

Returns the device pixel ratio for the device as a floating point number.

This function was introduced in Qt 5.6.

source

pub unsafe fn device_pixel_ratio_f_scale() -> c_double

Calls C++ function: static double QPaintDevice::devicePixelRatioFScale().

source

pub unsafe fn height(&self) -> c_int

Returns the height of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget).

Calls C++ function: int QPaintDevice::height() const.

C++ documentation:

Returns the height of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget).

See also heightMM().

source

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.

C++ documentation:

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

source

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.

C++ documentation:

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

source

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.

C++ documentation:

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

source

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.

C++ documentation:

Returns a pointer to the paint engine used for drawing on the device.

source

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.

C++ documentation:

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

source

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.

C++ documentation:

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

source

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.

C++ documentation:

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

source

pub unsafe fn width(&self) -> c_int

Returns the width of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget).

Calls C++ function: int QPaintDevice::width() const.

C++ documentation:

Returns the width of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget).

See also widthMM().

source

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.

C++ documentation:

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

source§

unsafe fn delete(&self)

Destroys the paint device and frees window system resources.

Calls C++ function: virtual [destructor] void QPaintDevice::~QPaintDevice().

C++ documentation:

Destroys the paint device and frees window system resources.

source§

impl DynamicCast<QBitmap> for QPaintDevice

source§

unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QBitmap>

Calls C++ function: QBitmap* dynamic_cast<QBitmap*>(QPaintDevice* ptr).

source§

impl DynamicCast<QImage> for QPaintDevice

source§

unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QImage>

Calls C++ function: QImage* dynamic_cast<QImage*>(QPaintDevice* ptr).

source§

impl DynamicCast<QOpenGLPaintDevice> for QPaintDevice

source§

unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QOpenGLPaintDevice>

Calls C++ function: QOpenGLPaintDevice* dynamic_cast<QOpenGLPaintDevice*>(QPaintDevice* ptr).

source§

impl DynamicCast<QOpenGLWindow> for QPaintDevice

source§

unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QOpenGLWindow>

Calls C++ function: QOpenGLWindow* dynamic_cast<QOpenGLWindow*>(QPaintDevice* ptr).

source§

impl DynamicCast<QPagedPaintDevice> for QPaintDevice

source§

unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QPagedPaintDevice>

Calls C++ function: QPagedPaintDevice* dynamic_cast<QPagedPaintDevice*>(QPaintDevice* ptr).

source§

impl DynamicCast<QPaintDeviceWindow> for QPaintDevice

source§

unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QPaintDeviceWindow>

Calls C++ function: QPaintDeviceWindow* dynamic_cast<QPaintDeviceWindow*>(QPaintDevice* ptr).

source§

impl DynamicCast<QPdfWriter> for QPaintDevice

source§

unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QPdfWriter>

Calls C++ function: QPdfWriter* dynamic_cast<QPdfWriter*>(QPaintDevice* ptr).

source§

impl DynamicCast<QPicture> for QPaintDevice

source§

unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QPicture>

Calls C++ function: QPicture* dynamic_cast<QPicture*>(QPaintDevice* ptr).

source§

impl DynamicCast<QPixmap> for QPaintDevice

source§

unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QPixmap>

Calls C++ function: QPixmap* dynamic_cast<QPixmap*>(QPaintDevice* ptr).

source§

impl DynamicCast<QRasterWindow> for QPaintDevice

source§

unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QRasterWindow>

Calls C++ function: QRasterWindow* dynamic_cast<QRasterWindow*>(QPaintDevice* ptr).

source§

impl StaticDowncast<QBitmap> for QPaintDevice

source§

unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QBitmap>

Calls C++ function: QBitmap* static_cast<QBitmap*>(QPaintDevice* ptr).

source§

impl StaticDowncast<QImage> for QPaintDevice

source§

unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QImage>

Calls C++ function: QImage* static_cast<QImage*>(QPaintDevice* ptr).

source§

impl StaticDowncast<QOpenGLPaintDevice> for QPaintDevice

source§

unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QOpenGLPaintDevice>

Calls C++ function: QOpenGLPaintDevice* static_cast<QOpenGLPaintDevice*>(QPaintDevice* ptr).

source§

impl StaticDowncast<QOpenGLWindow> for QPaintDevice

source§

unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QOpenGLWindow>

Calls C++ function: QOpenGLWindow* static_cast<QOpenGLWindow*>(QPaintDevice* ptr).

source§

impl StaticDowncast<QPagedPaintDevice> for QPaintDevice

source§

unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QPagedPaintDevice>

Calls C++ function: QPagedPaintDevice* static_cast<QPagedPaintDevice*>(QPaintDevice* ptr).

source§

impl StaticDowncast<QPaintDeviceWindow> for QPaintDevice

source§

unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QPaintDeviceWindow>

Calls C++ function: QPaintDeviceWindow* static_cast<QPaintDeviceWindow*>(QPaintDevice* ptr).

source§

impl StaticDowncast<QPdfWriter> for QPaintDevice

source§

unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QPdfWriter>

Calls C++ function: QPdfWriter* static_cast<QPdfWriter*>(QPaintDevice* ptr).

source§

impl StaticDowncast<QPicture> for QPaintDevice

source§

unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QPicture>

Calls C++ function: QPicture* static_cast<QPicture*>(QPaintDevice* ptr).

source§

impl StaticDowncast<QPixmap> for QPaintDevice

source§

unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QPixmap>

Calls C++ function: QPixmap* static_cast<QPixmap*>(QPaintDevice* ptr).

source§

impl StaticDowncast<QRasterWindow> for QPaintDevice

source§

unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QRasterWindow>

Calls C++ function: QRasterWindow* static_cast<QRasterWindow*>(QPaintDevice* ptr).

source§

impl StaticUpcast<QPaintDevice> for QBitmap

source§

unsafe fn static_upcast(ptr: Ptr<QBitmap>) -> Ptr<QPaintDevice>

Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QBitmap* ptr).

source§

impl StaticUpcast<QPaintDevice> for QImage

source§

unsafe fn static_upcast(ptr: Ptr<QImage>) -> Ptr<QPaintDevice>

Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QImage* ptr).

source§

impl StaticUpcast<QPaintDevice> for QOpenGLPaintDevice

source§

unsafe fn static_upcast(ptr: Ptr<QOpenGLPaintDevice>) -> Ptr<QPaintDevice>

Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QOpenGLPaintDevice* ptr).

source§

impl StaticUpcast<QPaintDevice> for QOpenGLWindow

source§

unsafe fn static_upcast(ptr: Ptr<QOpenGLWindow>) -> Ptr<QPaintDevice>

Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QOpenGLWindow* ptr).

source§

impl StaticUpcast<QPaintDevice> for QPagedPaintDevice

source§

unsafe fn static_upcast(ptr: Ptr<QPagedPaintDevice>) -> Ptr<QPaintDevice>

Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QPagedPaintDevice* ptr).

source§

impl StaticUpcast<QPaintDevice> for QPaintDeviceWindow

source§

unsafe fn static_upcast(ptr: Ptr<QPaintDeviceWindow>) -> Ptr<QPaintDevice>

Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QPaintDeviceWindow* ptr).

source§

impl StaticUpcast<QPaintDevice> for QPdfWriter

source§

unsafe fn static_upcast(ptr: Ptr<QPdfWriter>) -> Ptr<QPaintDevice>

Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QPdfWriter* ptr).

source§

impl StaticUpcast<QPaintDevice> for QPicture

source§

unsafe fn static_upcast(ptr: Ptr<QPicture>) -> Ptr<QPaintDevice>

Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QPicture* ptr).

source§

impl StaticUpcast<QPaintDevice> for QPixmap

source§

unsafe fn static_upcast(ptr: Ptr<QPixmap>) -> Ptr<QPaintDevice>

Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QPixmap* ptr).

source§

impl StaticUpcast<QPaintDevice> for QRasterWindow

source§

unsafe fn static_upcast(ptr: Ptr<QRasterWindow>) -> Ptr<QPaintDevice>

Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QRasterWindow* ptr).

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.