QScreen

The QScreen class is used to query screen properties. More

Inheritance diagram of PySide2.QtGui.QScreen

Synopsis

Functions

Signals

Detailed Description

A note on logical vs physical dots per inch: physical DPI is based on the actual physical pixel sizes when available, and is useful for print preview and other cases where it’s desirable to know the exact physical dimensions of screen displayed contents.

Logical dots per inch are used to convert font and user interface elements from point sizes to pixel sizes, and might be different from the physical dots per inch. The logical dots per inch are sometimes user-settable in the desktop environment’s settings panel, to let the user globally control UI and font sizes in different applications.

class PySide2.QtGui.QScreen
PySide2.QtGui.QScreen.angleBetween(a, b)
Parameters:
Return type:

int

Convenience function to compute the angle of rotation to get from rotation a to rotation b .

The result will be 0, 90, 180, or 270.

PrimaryOrientation is interpreted as the screen’s primaryOrientation() .

PySide2.QtGui.QScreen.availableGeometry()
Return type:

PySide2.QtCore.QRect

This property holds the screen’s available geometry in pixels.

The available geometry is the geometry excluding window manager reserved areas such as task bars and system menus.

Note, on X11 this will return the true available geometry only on systems with one monitor and if window manager has set _NET_WORKAREA atom. In all other cases this is equal to geometry() . This is a limitation in X11 window manager specification.

PySide2.QtGui.QScreen.availableGeometryChanged(geometry)
Parameters:

geometryPySide2.QtCore.QRect

PySide2.QtGui.QScreen.availableSize()
Return type:

PySide2.QtCore.QSize

This property holds the screen’s available size in pixels.

The available size is the size excluding window manager reserved areas such as task bars and system menus.

PySide2.QtGui.QScreen.availableVirtualGeometry()
Return type:

PySide2.QtCore.QRect

This property holds the available geometry of the virtual desktop to which this screen belongs.

Returns the available geometry of the virtual desktop corresponding to this screen.

This is the union of the virtual siblings’ individual available geometries.

PySide2.QtGui.QScreen.availableVirtualSize()
Return type:

PySide2.QtCore.QSize

This property holds the available size of the virtual desktop to which this screen belongs.

Returns the available pixel size of the virtual desktop corresponding to this screen.

This is the combined size of the virtual siblings’ individual available geometries.

PySide2.QtGui.QScreen.depth()
Return type:

int

This property holds the color depth of the screen.

PySide2.QtGui.QScreen.devicePixelRatio()
Return type:

float

This property holds the screen’s ratio between physical pixels and device-independent pixels.

Returns the ratio between physical pixels and device-independent pixels for the screen.

Common values are 1.0 on normal displays and 2.0 on “retina” displays. Higher values are also possible.

PySide2.QtGui.QScreen.geometry()
Return type:

PySide2.QtCore.QRect

This property holds the screen’s geometry in pixels.

As an example this might return QRect (0, 0, 1280, 1024), or in a virtual desktop setting QRect (1280, 0, 1280, 1024).

PySide2.QtGui.QScreen.geometryChanged(geometry)
Parameters:

geometryPySide2.QtCore.QRect

PySide2.QtGui.QScreen.grabWindow(window[, x=0[, y=0[, w=-1[, h=-1]]]])
Parameters:
  • windowWId

  • x – int

  • y – int

  • w – int

  • h – int

Return type:

PySide2.QtGui.QPixmap

Creates and returns a pixmap constructed by grabbing the contents of the given window restricted by QRect (x , y , width , height ).

The arguments (x , y ) specify the offset in the window, whereas (width , height ) specify the area to be copied. If width is negative, the function copies everything to the right border of the window. If height is negative, the function copies everything to the bottom of the window.

The offset and size arguments are specified in device independent pixels. The returned pixmap may be larger than the requested size when grabbing from a high-DPI screen. Call devicePixelRatio() to determine if this is the case.

The window system identifier (WId ) can be retrieved using the winId() function. The rationale for using a window identifier and not a QWidget , is to enable grabbing of windows that are not part of the application, window system frames, and so on.

Warning

Grabbing windows that are not part of the application is not supported on systems such as iOS, where sandboxing/security prevents reading pixels of windows not owned by the application.

The function grabs pixels from the screen, not from the window, i.e. if there is another window partially or entirely over the one you grab, you get pixels from the overlying window, too. The mouse cursor is generally not grabbed.

Note on X11 that if the given window doesn’t have the same depth as the root window, and another window partially or entirely obscures the one you grab, you will not get pixels from the overlying window. The contents of the obscured areas in the pixmap will be undefined and uninitialized.

On Windows Vista and above grabbing a layered window, which is created by setting the WA_TranslucentBackground attribute, will not work. Instead grabbing the desktop widget should work.

Warning

In general, grabbing an area outside the screen is not safe. This depends on the underlying window system.

PySide2.QtGui.QScreen.isLandscape(orientation)
Parameters:

orientationScreenOrientation

Return type:

bool

Convenience function that returns true if o is either landscape or inverted landscape; otherwise returns false .

PrimaryOrientation is interpreted as the screen’s primaryOrientation() .

PySide2.QtGui.QScreen.isPortrait(orientation)
Parameters:

orientationScreenOrientation

Return type:

bool

Convenience function that returns true if o is either portrait or inverted portrait; otherwise returns false .

PrimaryOrientation is interpreted as the screen’s primaryOrientation() .

PySide2.QtGui.QScreen.logicalDotsPerInch()
Return type:

float

This property holds the number of logical dots or pixels per inch.

This value can be used to convert font point sizes to pixel sizes.

This is a convenience property that’s simply the average of the logicalDotsPerInchX and logicalDotsPerInchY properties.

PySide2.QtGui.QScreen.logicalDotsPerInchChanged(dpi)
Parameters:

dpi – float

PySide2.QtGui.QScreen.logicalDotsPerInchX()
Return type:

float

This property holds the number of logical dots or pixels per inch in the horizontal direction.

This value is used to convert font point sizes to pixel sizes.

PySide2.QtGui.QScreen.logicalDotsPerInchY()
Return type:

float

This property holds the number of logical dots or pixels per inch in the vertical direction.

This value is used to convert font point sizes to pixel sizes.

PySide2.QtGui.QScreen.manufacturer()
Return type:

str

This property holds the manufacturer of the screen.

PySide2.QtGui.QScreen.mapBetween(a, b, rect)
Parameters:
Return type:

PySide2.QtCore.QRect

Maps the rect between two screen orientations.

This will flip the x and y dimensions of the rectangle rect if the orientation a is PortraitOrientation or InvertedPortraitOrientation and orientation b is LandscapeOrientation or InvertedLandscapeOrientation , or vice versa.

PrimaryOrientation is interpreted as the screen’s primaryOrientation() .

PySide2.QtGui.QScreen.model()
Return type:

str

This property holds the model of the screen.

PySide2.QtGui.QScreen.name()
Return type:

str

This property holds a user presentable string representing the screen.

For example, on X11 these correspond to the XRandr screen names, typically “VGA1”, “HDMI1”, etc.

PySide2.QtGui.QScreen.nativeOrientation()
Return type:

ScreenOrientation

This property holds the native screen orientation.

The native orientation of the screen is the orientation where the logo sticker of the device appears the right way up, or PrimaryOrientation if the platform does not support this functionality.

The native orientation is a property of the hardware, and does not change.

PySide2.QtGui.QScreen.orientation()
Return type:

ScreenOrientation

This property holds the screen orientation.

The screen orientation represents the physical orientation of the display. For example, the screen orientation of a mobile device will change based on how it is being held. A change to the orientation might or might not trigger a change to the primary orientation of the screen.

Changes to this property will be filtered by orientationUpdateMask() , so in order to receive orientation updates the application must first call setOrientationUpdateMask() with a mask of the orientations it wants to receive.

PrimaryOrientation is never returned.

PySide2.QtGui.QScreen.orientationChanged(orientation)
Parameters:

orientationScreenOrientation

PySide2.QtGui.QScreen.orientationUpdateMask()
Return type:

ScreenOrientations

Returns the currently set orientation update mask.

PySide2.QtGui.QScreen.physicalDotsPerInch()
Return type:

float

This property holds the number of physical dots or pixels per inch.

This value represents the pixel density on the screen’s display. Depending on what information the underlying system provides the value might not be entirely accurate.

This is a convenience property that’s simply the average of the physicalDotsPerInchX and physicalDotsPerInchY properties.

PySide2.QtGui.QScreen.physicalDotsPerInchChanged(dpi)
Parameters:

dpi – float

PySide2.QtGui.QScreen.physicalDotsPerInchX()
Return type:

float

This property holds the number of physical dots or pixels per inch in the horizontal direction.

This value represents the actual horizontal pixel density on the screen’s display. Depending on what information the underlying system provides the value might not be entirely accurate.

PySide2.QtGui.QScreen.physicalDotsPerInchY()
Return type:

float

This property holds the number of physical dots or pixels per inch in the vertical direction.

This value represents the actual vertical pixel density on the screen’s display. Depending on what information the underlying system provides the value might not be entirely accurate.

PySide2.QtGui.QScreen.physicalSize()
Return type:

PySide2.QtCore.QSizeF

This property holds the screen’s physical size (in millimeters).

The physical size represents the actual physical dimensions of the screen’s display.

Depending on what information the underlying system provides the value might not be entirely accurate.

PySide2.QtGui.QScreen.physicalSizeChanged(size)
Parameters:

sizePySide2.QtCore.QSizeF

PySide2.QtGui.QScreen.primaryOrientation()
Return type:

ScreenOrientation

This property holds the primary screen orientation.

The primary screen orientation is LandscapeOrientation if the screen geometry’s width is greater than or equal to its height, or PortraitOrientation otherwise. This property might change when the screen orientation was changed (i.e. when the display is rotated). The behavior is however platform dependent and can often be specified in an application manifest file.

PySide2.QtGui.QScreen.primaryOrientationChanged(orientation)
Parameters:

orientationScreenOrientation

PySide2.QtGui.QScreen.refreshRate()
Return type:

float

This property holds the approximate vertical refresh rate of the screen in Hz.

PySide2.QtGui.QScreen.refreshRateChanged(refreshRate)
Parameters:

refreshRate – float

PySide2.QtGui.QScreen.serialNumber()
Return type:

str

This property holds the serial number of the screen.

PySide2.QtGui.QScreen.setOrientationUpdateMask(mask)
Parameters:

maskScreenOrientations

Sets the orientations that the application is interested in receiving updates for in conjunction with this screen.

For example, to receive orientation() updates and thus have orientationChanged() signals being emitted for LandscapeOrientation and InvertedLandscapeOrientation, call with mask set to LandscapeOrientation | InvertedLandscapeOrientation .

The default, 0, means no orientationChanged() signals are fired.

PySide2.QtGui.QScreen.size()
Return type:

PySide2.QtCore.QSize

This property holds the pixel resolution of the screen.

PySide2.QtGui.QScreen.transformBetween(a, b, target)
Parameters:
Return type:

PySide2.QtGui.QTransform

Convenience function to compute a transform that maps from the coordinate system defined by orientation a into the coordinate system defined by orientation b and target dimensions target .

Example, a is Qt::Landscape, b is Qt::Portrait, and target is QRect (0, 0, w, h) the resulting transform will be such that the point QPoint (0, 0) is mapped to QPoint (0, w), and QPoint (h, w) is mapped to QPoint (0, h). Thus, the landscape coordinate system QRect (0, 0, h, w) is mapped (with a 90 degree rotation) into the portrait coordinate system QRect (0, 0, w, h).

PrimaryOrientation is interpreted as the screen’s primaryOrientation() .

PySide2.QtGui.QScreen.virtualGeometry()
Return type:

PySide2.QtCore.QRect

This property holds the pixel geometry of the virtual desktop to which this screen belongs.

Returns the pixel geometry of the virtual desktop corresponding to this screen.

This is the union of the virtual siblings’ individual geometries.

PySide2.QtGui.QScreen.virtualGeometryChanged(rect)
Parameters:

rectPySide2.QtCore.QRect

PySide2.QtGui.QScreen.virtualSiblingAt(point)
Parameters:

pointPySide2.QtCore.QPoint

Return type:

PySide2.QtGui.QScreen

Returns the screen at point within the set of virtualSiblings() , or nullptr if outside of any screen.

The point is in relation to the virtualGeometry() of each set of virtual siblings.

PySide2.QtGui.QScreen.virtualSiblings()
Return type:

Get the screen’s virtual siblings.

The virtual siblings are the screen instances sharing the same virtual desktop. They share a common coordinate system, and windows can freely be moved or positioned across them without having to be re-created.

PySide2.QtGui.QScreen.virtualSize()
Return type:

PySide2.QtCore.QSize

This property holds the pixel size of the virtual desktop to which this screen belongs.

Returns the pixel size of the virtual desktop corresponding to this screen.

This is the combined size of the virtual siblings’ individual geometries.