PySide6.QtGui.QPaintDevice¶
- class QPaintDevice¶
- The - QPaintDeviceclass is the base class of objects that can be painted on with- QPainter. More…- Inherited by: - QSvgGenerator,- QOpenGLPaintDevice,- QPicture,- QPagedPaintDevice,- QPrinter,- QPixmap,- QImage,- QBitmap,- QWidget,- QWizardPage,- QToolBar,- QTabWidget,- QTabBar,- QStatusBar,- QSplitterHandle,- QSplashScreen,- QSizeGrip,- QRubberBand,- QRhiWidget,- QProgressBar,- QMenuBar,- QMenu,- QMdiSubWindow,- QMainWindow,- QLineEdit,- QKeySequenceEdit,- QGroupBox,- QFrame,- QToolBox,- QStackedWidget,- QSplitter,- QLabel,- QLCDNumber,- QAbstractScrollArea,- QTextEdit,- QTextBrowser,- QScrollArea,- QPlainTextEdit,- QMdiArea,- QGraphicsView,- QAbstractItemView,- QTreeView,- QTreeWidget,- QHelpContentWidget,- QTableView,- QTableWidget,- QListView,- QUndoView,- QListWidget,- QHelpIndexWidget,- QHeaderView,- QColumnView,- QPdfView,- QFocusFrame,- QDockWidget,- QDialogButtonBox,- QDialog,- QWizard,- QProgressDialog,- QMessageBox,- QInputDialog,- QFontDialog,- QErrorMessage,- QColorDialog,- QPrintPreviewDialog,- QPageSetupDialog,- QAbstractPrintDialog,- QPrintDialog,- QComboBox,- QFontComboBox,- QCalendarWidget,- QAbstractSpinBox,- QSpinBox,- QDoubleSpinBox,- QDateTimeEdit,- QTimeEdit,- QDateEdit,- QAbstractSlider,- QSlider,- QScrollBar,- QDial,- QAbstractButton,- QToolButton,- QRadioButton,- QPushButton,- QCommandLinkButton,- QCheckBox,- QSvgWidget,- QQuickWidget,- QPrintPreviewWidget,- QPdfPageSelector,- QOpenGLWidget,- QVideoWidget,- QHelpSearchResultWidget,- QHelpSearchQueryWidget,- QHelpFilterSettingsWidget,- QDesignerWidgetBoxInterface,- QDesignerPropertyEditorInterface,- QDesignerObjectInspectorInterface,- QDesignerFormWindowInterface,- QDesignerActionEditorInterface,- QPaintDeviceWindow,- QOpenGLWindow,- QRasterWindow,- QPdfWriter,- QFileDialog,- QWebEngineView,- QChartView- Synopsis¶- Methods¶- def - __init__()
- def - colorCount()
- def - depth()
- def - height()
- def - heightMM()
- def - logicalDpiX()
- def - logicalDpiY()
- def - paintingActive()
- def - physicalDpiX()
- def - physicalDpiY()
- def - width()
- def - widthMM()
 - Virtual methods¶- def - devType()
- def - initPainter()
- def - metric()
- def - paintEngine()
- def - redirected()
- def - sharedPainter()
 - Static functions¶- Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- 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 - QPaintDeviceare currently implemented by the QWidget,- QImage,- QPixmap,- QPicture, and QPrinter subclasses.- To implement support for a new backend, you must derive from - QPaintDeviceand reimplement the virtual- paintEngine()function to tell- QPainterwhich 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- QPaintEngineand reimplement its virtual functions.- Warning - Qt requires that a - QGuiApplicationobject 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 - QPaintDeviceclass 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- QPixmapand 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- PaintDeviceMetricas 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- QPaintEnginemust handle the mapping. Finally, the- colorCount()function returns the number of different colors available for the paint device.- class 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 - QPixmapand QWidget). See also- width().- QPaintDevice.PdmHeight - The height of the paint device in default coordinate system units (e.g. pixels for - QPixmapand QWidget). See also- height().- QPaintDevice.PdmWidthMM - The width of the paint device in millimeters. See also - widthMM().- QPaintDevice.PdmHeightMM - The height of the paint device in millimeters. See also - heightMM().- QPaintDevice.PdmNumColors - The number of different colors available for the paint device. See also - colorCount().- QPaintDevice.PdmDepth - The bit depth (number of bit planes) of the paint device. See also - depth().- QPaintDevice.PdmDpiX - The horizontal resolution of the device in dots per inch. See also - logicalDpiX().- QPaintDevice.PdmDpiY - The vertical resolution of the device in dots per inch. See also - logicalDpiY().- QPaintDevice.PdmPhysicalDpiX - The horizontal resolution of the device in dots per inch. See also - physicalDpiX().- QPaintDevice.PdmPhysicalDpiY - The vertical resolution of the device in dots per inch. See also - physicalDpiY().- QPaintDevice.PdmDevicePixelRatio - The device pixel ratio for device. Common values are 1 for normal-dpi displays and 2 for high-dpi “retina” displays. - QPaintDevice.PdmDevicePixelRatioScaled - The scaled device pixel ratio for the device. This is identical to PdmDevicePixelRatio, except that the value is scaled by a constant factor in order to support paint devices with fractional scale factors. The constant scaling factor used is devicePixelRatioFScale(). This enum value has been introduced in Qt 5.6. - QPaintDevice.PdmDevicePixelRatioF_EncodedA - This enum item, together with the corresponding - Bitem, are used together for the device pixel ratio of the device, as an encoded- doublefloating point value. A- QPaintDevicesubclass that supports fractional DPR values should implement support for these two enum items in its override of the- metric()function. The return value is expected to be the result of the encodeMetricF() function.- QPaintDevice.PdmDevicePixelRatioF_EncodedB - See PdmDevicePixelRatioF_EncodedA. - See also 
 - PySide6.QtGui.QPaintDevice.painters¶
 - __init__()¶
 - Constructs a paint device. This constructor can be invoked only from subclasses of - QPaintDevice.- colorCount()¶
- Return type:
- 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. - depth()¶
- Return type:
- int 
 
 - Returns the bit depth (number of bit planes) of the paint device. - devType()¶
- Return type:
- int 
 
 - devicePixelRatio()¶
- Return type:
- float 
 
 - Returns the device pixel ratio for device. - Common values are 1 for normal-dpi displays and 2 for high-dpi “retina” displays. - devicePixelRatioF()¶
- Return type:
- float 
 
 - Returns the device pixel ratio for the device as a floating point number. - static devicePixelRatioFScale()¶
- Return type:
- float 
 
 - static encodeMetricF(metric, value)¶
- Parameters:
- metric – - PaintDeviceMetric
- value – float 
 
- Return type:
- int 
 
 - height()¶
- Return type:
- int 
 
 - Returns the height of the paint device in default coordinate system units (e.g. pixels for - QPixmapand QWidget).- See also - heightMM()¶
- Return type:
- 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. - See also - logicalDpiX()¶
- Return type:
- 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().- Note that if the logicalDpiX() doesn’t equal the - physicalDpiX(), the corresponding- QPaintEnginemust handle the resolution mapping.- See also - logicalDpiY()¶
- Return type:
- 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().- Note that if the logicalDpiY() doesn’t equal the - physicalDpiY(), the corresponding- QPaintEnginemust handle the resolution mapping.- See also - metric(metric)¶
- Parameters:
- metric – - PaintDeviceMetric
- Return type:
- int 
 
 - Returns the metric information for the given paint device - metric.- See also - abstract paintEngine()¶
- Return type:
 
 - Returns a pointer to the paint engine used for drawing on the device. - paintingActive()¶
- Return type:
- bool 
 
 - Returns - trueif the device is currently being painted on, i.e. someone has called- begin()but not yet called- end()for this device; otherwise returns- false.- See also - physicalDpiX()¶
- Return type:
- 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 physicalDpiX() doesn’t equal the - logicalDpiX(), the corresponding- QPaintEnginemust handle the resolution mapping.- See also - physicalDpiY()¶
- Return type:
- 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 physicalDpiY() doesn’t equal the - logicalDpiY(), the corresponding- QPaintEnginemust handle the resolution mapping.- See also - Return type:
 
 - width()¶
- Return type:
- int 
 
 - Returns the width of the paint device in default coordinate system units (e.g. pixels for - QPixmapand QWidget).- See also - widthMM()¶
- Return type:
- 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. - See also