Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QPaintDevice Class

TheQPaintDevice class is the base class of objects that can be painted.More...

Public Types

enumPaintDeviceMetric { PdmWidth, PdmHeight, PdmWidthMM, PdmHeightMM, ..., PdmPhysicalDpiY }

Public Functions

virtual~QPaintDevice()
intcolorCount() const
intdepth() const
intheight() const
intheightMM() const
intlogicalDpiX() const
intlogicalDpiY() const
virtual QPaintEngine *paintEngine() const = 0
boolpaintingActive() const
intphysicalDpiX() const
intphysicalDpiY() const
intwidth() const
intwidthMM() const

Protected Functions

QPaintDevice()
virtual intmetric(PaintDeviceMetric metric) const

Detailed Description

TheQPaintDevice 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 aQPainter. 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 ofQPaintDevice are currently implemented by theQWidget,QImage,QPixmap,QGLPixelBuffer,QPicture, andQPrinter subclasses.

To implement support for a new backend, you must derive fromQPaintDevice and reimplement the virtualpaintEngine() function to tellQPainter 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 fromQPaintEngine and reimplement its virtual functions.

Warning: Qt requires that aQApplication 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.

TheQPaintDevice class 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 forQPixmap andQWidget) 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 as argument.

ThelogicalDpiX() 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 correspondingQPaintEngine must handle the mapping. Finally, thecolorCount() function returns the number of different colors available for the paint device.

See alsoQPaintEngine,QPainter,Coordinate System, andPaint System.

Member Type Documentation

enum QPaintDevice::PaintDeviceMetric

Describes the various metrics of a paint device.

ConstantValueDescription
QPaintDevice::PdmWidth1The width of the paint device in default coordinate system units (e.g. pixels forQPixmap andQWidget). See alsowidth().
QPaintDevice::PdmHeight2The height of the paint device in default coordinate system units (e.g. pixels forQPixmap andQWidget). See alsoheight().
QPaintDevice::PdmWidthMM3The width of the paint device in millimeters. See alsowidthMM().
QPaintDevice::PdmHeightMM4The height of the paint device in millimeters. See alsoheightMM().
QPaintDevice::PdmNumColors5The number of different colors available for the paint device. See alsocolorCount().
QPaintDevice::PdmDepth6The bit depth (number of bit planes) of the paint device. See alsodepth().
QPaintDevice::PdmDpiX7The horizontal resolution of the device in dots per inch. See alsologicalDpiX().
QPaintDevice::PdmDpiY8The vertical resolution of the device in dots per inch. See alsologicalDpiY().
QPaintDevice::PdmPhysicalDpiX9The horizontal resolution of the device in dots per inch. See alsophysicalDpiX().
QPaintDevice::PdmPhysicalDpiY10The vertical resolution of the device in dots per inch. See alsophysicalDpiY().

See alsometric().

Member Function Documentation

[protected]QPaintDevice::QPaintDevice()

Constructs a paint device. This constructor can be invoked only from subclasses ofQPaintDevice.

[virtual]QPaintDevice::~QPaintDevice()

Destroys the paint device and frees window system resources.

int QPaintDevice::colorCount() const

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.

int QPaintDevice::depth() const

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

int QPaintDevice::height() const

Returns the height of the paint device in default coordinate system units (e.g. pixels forQPixmap andQWidget).

See alsoheightMM().

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

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

Note that if the logicalDpiX() doesn't equal thephysicalDpiX(), the correspondingQPaintEngine must handle the resolution mapping.

See alsologicalDpiY() andphysicalDpiX().

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

Note that if the logicalDpiY() doesn't equal thephysicalDpiY(), the correspondingQPaintEngine must handle the resolution mapping.

See alsologicalDpiX() andphysicalDpiY().

[virtual protected]int QPaintDevice::metric(PaintDeviceMetric metric) const

Returns the metric information for the given paint devicemetric.

See alsoPaintDeviceMetric.

[pure virtual]QPaintEngine * QPaintDevice::paintEngine() const

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

bool QPaintDevice::paintingActive() const

Returns true if the device is currently being painted on, i.e. someone has calledQPainter::begin() but not yet calledQPainter::end() for this device; otherwise returns false.

See alsoQPainter::isActive().

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 thelogicalDpiX(), the correspondingQPaintEngine must handle the resolution mapping.

See alsophysicalDpiY() andlogicalDpiX().

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 thelogicalDpiY(), the correspondingQPaintEngine must handle the resolution mapping.

See alsophysicalDpiX() andlogicalDpiY().

int QPaintDevice::width() const

Returns the width of the paint device in default coordinate system units (e.g. pixels forQPixmap andQWidget).

See alsowidthMM().

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

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp