Table Of Contents

Previous topic

QColor

Next topic

QPrinter

QPaintDevice

Inherited by: QGLPixelBuffer, QGLFramebufferObject, QPrinter, QSvgGenerator, QPicture, QPixmap, QImage, QBitmap, QWidget, QDesktopWidget, QHelpSearchResultWidget, QHelpSearchQueryWidget, QComboBox, QCalendarWidget, QAbstractButton, QPushButton, QCommandLinkButton, QCheckBox, QWizardPage, QWebInspector, QLineEdit, QSvgWidget, Phonon.VolumeSlider, Phonon.VideoPlayer, Phonon.SeekSlider, QWorkspace, QToolButton, QFrame, QToolBox, QAbstractScrollArea, QGraphicsView, QDeclarativeView, QAbstractItemView, QTreeView, QHelpContentWidget, QTreeWidget, QHeaderView, QTableView, QTableWidget, QColumnView, QListView, QUndoView, QListWidget, QHelpIndexWidget, QToolBar, QRubberBand, QTabWidget, QStatusBar, QTabBar, Phonon.EffectWidget, QStackedWidget, QSplitterHandle, QAbstractSlider, QSlider, QDial, QSplitter, QAbstractSpinBox, QDateTimeEdit, QTimeEdit, QDateEdit, QSplashScreen, QDoubleSpinBox, QSpinBox, QSizeGrip, QScrollBar, QScrollArea, QRadioButton, QProgressBar, QDialog, QAbstractPrintDialog, QPrintDialog, QAbstractPageSetupDialog, QPageSetupDialog, QFileDialog, QWizard, QProgressDialog, QPrintPreviewDialog, QFontDialog, QMessageBox, QInputDialog, QErrorMessage, QColorDialog, QPrintPreviewWidget, QPlainTextEdit, QTextEdit, QTextBrowser, QMenuBar, QMenu, QMdiSubWindow, QMdiArea, QMainWindow, QLCDNumber, QLabel, QGroupBox, QFontComboBox, QFocusFrame, QDockWidget, QGLWidget, QDialogButtonBox, QWebView

Synopsis

Functions

Virtual functions

Detailed Description

The PySide.QtGui.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 PySide.QtGui.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 PySide.QtGui.QPaintDevice are currently implemented by the PySide.QtGui.QWidget , PySide.QtGui.QImage , PySide.QtGui.QPixmap , PySide.QtOpenGL.QGLPixelBuffer , PySide.QtGui.QPicture , and PySide.QtGui.QPrinter subclasses.

To implement support for a new backend, you must derive from PySide.QtGui.QPaintDevice and reimplement the virtual PySide.QtGui.QPaintDevice.paintEngine() function to tell PySide.QtGui.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 PySide.QtGui.QPaintEngine and reimplement its virtual functions.

Warning

Qt requires that a PySide.QtGui.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 PySide.QtGui.QPaintDevice class provides several functions returning the various device metrics: The PySide.QtGui.QPaintDevice.depth() function returns its bit depth (number of bit planes). The PySide.QtGui.QPaintDevice.height() function returns its height in default coordinate system units (e.g. pixels for PySide.QtGui.QPixmap and PySide.QtGui.QWidget ) while PySide.QtGui.QPaintDevice.heightMM() returns the height of the device in millimeters. Similiarily, the PySide.QtGui.QPaintDevice.width() and PySide.QtGui.QPaintDevice.widthMM() functions return the width of the device in default coordinate system units and in millimeters, respectively. Alternatively, the protected PySide.QtGui.QPaintDevice.metric() function can be used to retrieve the metric information by specifying the desired QPaintDevice.PaintDeviceMetric as argument.

The PySide.QtGui.QPaintDevice.logicalDpiX() and PySide.QtGui.QPaintDevice.logicalDpiY() functions return the horizontal and vertical resolution of the device in dots per inch. The PySide.QtGui.QPaintDevice.physicalDpiX() and PySide.QtGui.QPaintDevice.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 PySide.QtGui.QPaintEngine must handle the mapping. Finally, the PySide.QtGui.QPaintDevice.colorCount() function returns the number of different colors available for the paint device.

See also

PySide.QtGui.QPaintEngine PySide.QtGui.QPainter Coordinate System Paint System

class PySide.QtGui.QPaintDevice

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

PySide.QtGui.QPaintDevice.PaintDeviceMetric

Describes the various metrics of a paint device.

Constant Description
QPaintDevice.PdmWidth The width of the paint device in default coordinate system units (e.g. pixels for PySide.QtGui.QPixmap and PySide.QtGui.QWidget ). See also PySide.QtGui.QPaintDevice.width() .
QPaintDevice.PdmHeight The height of the paint device in default coordinate system units (e.g. pixels for PySide.QtGui.QPixmap and PySide.QtGui.QWidget ). See also PySide.QtGui.QPaintDevice.height() .
QPaintDevice.PdmWidthMM The width of the paint device in millimeters. See also PySide.QtGui.QPaintDevice.widthMM() .
QPaintDevice.PdmHeightMM The height of the paint device in millimeters. See also PySide.QtGui.QPaintDevice.heightMM() .
QPaintDevice.PdmNumColors The number of different colors available for the paint device. See also PySide.QtGui.QPaintDevice.colorCount() .
QPaintDevice.PdmDepth The bit depth (number of bit planes) of the paint device. See also PySide.QtGui.QPaintDevice.depth() .
QPaintDevice.PdmDpiX The horizontal resolution of the device in dots per inch. See also PySide.QtGui.QPaintDevice.logicalDpiX() .
QPaintDevice.PdmDpiY The vertical resolution of the device in dots per inch. See also PySide.QtGui.QPaintDevice.logicalDpiY() .
QPaintDevice.PdmPhysicalDpiX The horizontal resolution of the device in dots per inch. See also PySide.QtGui.QPaintDevice.physicalDpiX() .
QPaintDevice.PdmPhysicalDpiY The vertical resolution of the device in dots per inch. See also PySide.QtGui.QPaintDevice.physicalDpiY() .
PySide.QtGui.QPaintDevice.painters
PySide.QtGui.QPaintDevice.colorCount()
Return type:PySide.QtCore.int

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.

PySide.QtGui.QPaintDevice.depth()
Return type:PySide.QtCore.int

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

PySide.QtGui.QPaintDevice.devType()
Return type:PySide.QtCore.int

Returns the device type identifier, which is QInternal.Widget if the device is a PySide.QtGui.QWidget , QInternal.Pixmap if it’s a PySide.QtGui.QPixmap , QInternal.Printer if it’s a PySide.QtGui.QPrinter , QInternal.Picture if it’s a PySide.QtGui.QPicture , or QInternal.UnknownDevice in other cases.

PySide.QtGui.QPaintDevice.height()
Return type:PySide.QtCore.int

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

PySide.QtGui.QPaintDevice.heightMM()
Return type:PySide.QtCore.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.

PySide.QtGui.QPaintDevice.logicalDpiX()
Return type:PySide.QtCore.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 PySide.QtGui.QPaintDevice.widthMM() .

Note that if the PySide.QtGui.QPaintDevice.logicalDpiX() doesn’t equal the PySide.QtGui.QPaintDevice.physicalDpiX() , the corresponding PySide.QtGui.QPaintEngine must handle the resolution mapping.

PySide.QtGui.QPaintDevice.logicalDpiY()
Return type:PySide.QtCore.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 PySide.QtGui.QPaintDevice.heightMM() .

Note that if the PySide.QtGui.QPaintDevice.logicalDpiY() doesn’t equal the PySide.QtGui.QPaintDevice.physicalDpiY() , the corresponding PySide.QtGui.QPaintEngine must handle the resolution mapping.

PySide.QtGui.QPaintDevice.metric(metric)
Parameters:metricPySide.QtGui.QPaintDevice.PaintDeviceMetric
Return type:PySide.QtCore.int

Returns the metric information for the given paint device metric .

See also

QPaintDevice.PaintDeviceMetric

PySide.QtGui.QPaintDevice.numColors()
Return type:PySide.QtCore.int

Use PySide.QtGui.QPaintDevice.colorCount() instead.

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.

PySide.QtGui.QPaintDevice.paintEngine()
Return type:PySide.QtGui.QPaintEngine

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

PySide.QtGui.QPaintDevice.paintingActive()
Return type:PySide.QtCore.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.

PySide.QtGui.QPaintDevice.physicalDpiX()
Return type:PySide.QtCore.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 PySide.QtGui.QPaintDevice.physicalDpiX() doesn’t equal the PySide.QtGui.QPaintDevice.logicalDpiX() , the corresponding PySide.QtGui.QPaintEngine must handle the resolution mapping.

PySide.QtGui.QPaintDevice.physicalDpiY()
Return type:PySide.QtCore.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 PySide.QtGui.QPaintDevice.physicalDpiY() doesn’t equal the PySide.QtGui.QPaintDevice.logicalDpiY() , the corresponding PySide.QtGui.QPaintEngine must handle the resolution mapping.

PySide.QtGui.QPaintDevice.width()
Return type:PySide.QtCore.int

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

PySide.QtGui.QPaintDevice.widthMM()
Return type:PySide.QtCore.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.