Qt:Документация 4.3.2/qpaintdevice

Материал из Wiki.crossplatform.ru

Версия от 14:32, 6 ноября 2008; Root (Обсуждение | вклад)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск
40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

Главная · Все классы · Основные классы · Классы по группам · Модули · Функции

Image:trolltech-logo.png

Содержание

[править] QPaintDevice Class Reference
[модуль QtGui ]

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

 #include <QPaintDevice>

Inherited by QCustomRasterPaintDevice, QGLFramebufferObject, QGLPixelBuffer, QImage, QPicture, QPixmap, QPrinter, QSvgGenerator, and QWidget.

[править] Открытые типы

  • enum PaintDeviceMetric { PdmWidth, PdmHeight, PdmWidthMM, PdmHeightMM, ..., PdmPhysicalDpiY }

[править] Открытые функции

[править] Защищенные функции


[править] Подробное описание

The QPaintDevice 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 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 QApplication 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 vertical resolution differ, the corresponding QPaintEngine must handle the mapping. Finally, the numColors() function returns the number of different colors available for the paint device.

See also QPaintEngine, QPainter, The Coordinate System, and The Paint System.


[править] Описание типов членов

[править]
enum QPaintDevice::PaintDeviceMetric

Describes the various metrics of a paint device.


Constant Value Description
QPaintDevice::PdmWidth 1 The width of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget). See also width().
QPaintDevice::PdmHeight 2 The height of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget). See also height().
QPaintDevice::PdmWidthMM 3 The width of the paint device in millimeters. See also widthMM().
QPaintDevice::PdmHeightMM 4 The height of the paint device in millimeters. See also heightMM().
QPaintDevice::PdmNumColors 5 The number of different colors available for the paint device. See also numColors().
QPaintDevice::PdmDepth 6 The bit depth (number of bit planes) of the paint device. See also depth().
QPaintDevice::PdmDpiX 7 The horizontal resolution of the device in dots per inch. See also logicalDpiX().
QPaintDevice::PdmDpiY 8 The vertical resolution of the device in dots per inch. See also logicalDpiY().
QPaintDevice::PdmPhysicalDpiX 9 The horizontal resolution of the device in dots per inch. See also physicalDpiX().
QPaintDevice::PdmPhysicalDpiY 10 The vertical resolution of the device in dots per inch. See also physicalDpiY().

See also metric().


[править] Описание функций-членов

[править]
QPaintDevice::QPaintDevice () [protected]

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

[править]
QPaintDevice::~QPaintDevice () [virtual]

Destroys the paint device and frees window system resources.

[править]
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 for QPixmap and QWidget).

See also heightMM().

[править]
int QPaintDevice::heightMM () const

Returns the height of the paint device in millimeters.

See also height().

[править]
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(), but it varies on Windows.

Note that if the logicalDpiX() doesn't equal the physicalDpiX(), the corresponding QPaintEngine must handle the resolution mapping.

See also logicalDpiY() and physicalDpiX().

[править]
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(), but it varies on Windows.

Note that if the logicalDpiY() doesn't equal the physicalDpiY(), the corresponding QPaintEngine must handle the resolution mapping.

See also logicalDpiX() and physicalDpiY().

[править]
int QPaintDevice::metric ( PaintDeviceMetric metric ) const [virtual protected]

Returns the metric information for the given paint device metric.

See also PaintDeviceMetric.

[править]
int QPaintDevice::numColors () 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.

[править]
QPaintEngine * QPaintDevice::paintEngine () const [pure virtual]

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 called QPainter::begin() but not yet called QPainter::end() for this device; otherwise returns false.

See also QPainter::isActive().

[править]
int QPaintDevice::physicalDpiX () const

Returns the horizontal resolution of the device in dots per inch.

Note that if the physicalDpiX() doesn't equal the logicalDpiX(), the corresponding QPaintEngine must handle the resolution mapping.

See also physicalDpiY() and logicalDpiX().

[править]
int QPaintDevice::physicalDpiY () const

Returns the horizontal resolution of the device in dots per inch.

Note that if the physicalDpiY() doesn't equal the logicalDpiY(), the corresponding QPaintEngine must handle the resolution mapping.

See also physicalDpiX() and logicalDpiY().

[править]
int QPaintDevice::width () const

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

See also widthMM().

[править]
int QPaintDevice::widthMM () const

Returns the width of the paint device in millimeters.

See also width().


Copyright © 2007 Trolltech Trademarks
Qt 4.3.2