- class QScreen¶
The
QScreen
class is used to query screen properties. More…Synopsis¶
Properties¶
availableGeometryᅟ
- The screen’s available geometry in pixelsavailableSizeᅟ
- The screen’s available size in pixelsavailableVirtualGeometryᅟ
- The available geometry of the virtual desktop to which this screen belongsavailableVirtualSizeᅟ
- The available size of the virtual desktop to which this screen belongsdepthᅟ
- The color depth of the screendevicePixelRatioᅟ
- The screen’s ratio between physical pixels and device-independent pixelsgeometryᅟ
- The screen’s geometry in pixelslogicalDotsPerInchᅟ
- The number of logical dots or pixels per inchlogicalDotsPerInchXᅟ
- The number of logical dots or pixels per inch in the horizontal directionlogicalDotsPerInchYᅟ
- The number of logical dots or pixels per inch in the vertical directionmanufacturerᅟ
- The manufacturer of the screenmodelᅟ
- The model of the screennameᅟ
- User presentable string representing the screennativeOrientationᅟ
- The native screen orientationorientationᅟ
- The screen orientationphysicalDotsPerInchᅟ
- The number of physical dots or pixels per inchphysicalDotsPerInchXᅟ
- The number of physical dots or pixels per inch in the horizontal directionphysicalDotsPerInchYᅟ
- The number of physical dots or pixels per inch in the vertical directionphysicalSizeᅟ
- The screen’s physical size (in millimeters)primaryOrientationᅟ
- The primary screen orientationrefreshRateᅟ
- The approximate vertical refresh rate of the screen in HzserialNumberᅟ
- The serial number of the screensizeᅟ
- The pixel resolution of the screenvirtualGeometryᅟ
- The pixel geometry of the virtual desktop to which this screen belongsvirtualSizeᅟ
- The pixel size of the virtual desktop to which this screen belongs
Methods¶
def
angleBetween()
def
availableSize()
def
depth()
def
geometry()
def
grabWindow()
def
isLandscape()
def
isPortrait()
def
manufacturer()
def
mapBetween()
def
model()
def
name()
def
orientation()
def
physicalSize()
def
refreshRate()
def
serialNumber()
def
size()
def
virtualSize()
Signals¶
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 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.
Note
Both physical and logical DPI are expressed in device-independent dots. Multiply by
devicePixelRatio()
to get device-dependent density.Note
Properties can be used directly when
from __feature__ import true_property
is used or via accessor functions otherwise.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.- Access functions:
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.
- Access functions:
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.
See also
- Access functions:
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.
See also
- Access functions:
- property depthᅟ: int¶
This property holds the color depth of the screen.
- Access functions:
- property devicePixelRatioᅟ: 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.
See also
- Access functions:
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).
- Access functions:
Signal
geometryChanged()
- property logicalDotsPerInchᅟ: 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
andlogicalDotsPerInchY
properties.- Access functions:
- property logicalDotsPerInchXᅟ: 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.
See also
- Access functions:
- property logicalDotsPerInchYᅟ: 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.
See also
- Access functions:
- property manufacturerᅟ: str¶
This property holds the manufacturer of the screen.
- Access functions:
- property modelᅟ: str¶
This property holds the model of the screen.
- Access functions:
- property nameᅟ: 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.
Note
The user presentable string is not guaranteed to match the result of any native APIs, and should not be used to uniquely identify a screen.
- Access functions:
- property nativeOrientationᅟ: Qt.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 Qt::PrimaryOrientation if the platform does not support this functionality.
The native orientation is a property of the hardware, and does not change.
- Access functions:
- property orientationᅟ: Qt.ScreenOrientation¶
This property holds the screen orientation.
The
orientation
property tells the orientation of the screen from the window system perspective.Most mobile devices and tablet computers contain accelerometer sensors. The Qt Sensors module provides the ability to read this sensor directly. However, the windowing system may rotate the entire screen automatically based on how it is being held; in that case, this
orientation
property will change.See also
- Access functions:
- property physicalDotsPerInchᅟ: 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
andphysicalDotsPerInchY
properties.Note
Physical DPI is expressed in device-independent dots. Multiply by
devicePixelRatio()
to get device-dependent density.- Access functions:
- property physicalDotsPerInchXᅟ: 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.
Note
Physical DPI is expressed in device-independent dots. Multiply by
devicePixelRatio()
to get device-dependent density.See also
- Access functions:
- property physicalDotsPerInchYᅟ: 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.
Note
Physical DPI is expressed in device-independent dots. Multiply by
devicePixelRatio()
to get device-dependent density.See also
- Access functions:
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.
- Access functions:
- property primaryOrientationᅟ: Qt.ScreenOrientation¶
This property holds the primary screen orientation.
The primary screen orientation is Qt::LandscapeOrientation if the screen geometry’s width is greater than or equal to its height, or Qt::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.
- Access functions:
- property refreshRateᅟ: float¶
This property holds the approximate vertical refresh rate of the screen in Hz.
Warning
Avoid using the screen’s refresh rate to drive animations via a timer such as QChronoTimer. Instead use
requestUpdate()
.See also
- Access functions:
- property serialNumberᅟ: str¶
This property holds the serial number of the screen.
- Access functions:
This property holds the pixel resolution of the screen.
- Access functions:
Signal
geometryChanged()
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.
See also
- Access functions:
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.
See also
- Access functions:
- angleBetween(a, b)¶
- Parameters:
- Return type:
int
Convenience function to compute the angle of rotation to get from rotation
a
to rotationb
.The result will be 0, 90, 180, or 270.
Qt::PrimaryOrientation is interpreted as the screen’s
primaryOrientation()
.Getter of property
availableGeometryᅟ
.Notification signal of property
availableSizeᅟ
.Getter of property
availableSizeᅟ
.Getter of property
availableVirtualGeometryᅟ
.Getter of property
availableVirtualSizeᅟ
.- depth()¶
- Return type:
int
Getter of property
depthᅟ
.- devicePixelRatio()¶
- Return type:
float
Getter of property
devicePixelRatioᅟ
.Getter of property
geometryᅟ
.Notification signal of property
sizeᅟ
.- grabWindow([window=0[, x=0[, y=0[, w=-1[, h=-1]]]]])¶
- Parameters:
window –
WId
x – int
y – int
w – int
h – int
- Return type:
Creates and returns a pixmap constructed by grabbing the contents of the given
window
restricted by QRect(x
,y
,width
,height
). Ifwindow
is 0, then the entire screen will be grabbed.The arguments (
x
,y
) specify the offset in the window, whereas (width
,height
) specify the area to be copied. Ifwidth
is negative, the function copies everything to the right border of the window. Ifheight
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 QWidget::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 grabWindow() 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 Qt::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.
- isLandscape(orientation)¶
- Parameters:
orientation –
ScreenOrientation
- Return type:
bool
Convenience function that returns
true
ifo
is either landscape or inverted landscape; otherwise returnsfalse
.Qt::PrimaryOrientation is interpreted as the screen’s
primaryOrientation()
.- isPortrait(orientation)¶
- Parameters:
orientation –
ScreenOrientation
- Return type:
bool
Convenience function that returns
true
ifo
is either portrait or inverted portrait; otherwise returnsfalse
.Qt::PrimaryOrientation is interpreted as the screen’s
primaryOrientation()
.- logicalDotsPerInch()¶
- Return type:
float
Getter of property
logicalDotsPerInchᅟ
.- logicalDotsPerInchChanged(dpi)¶
- Parameters:
dpi – float
Notification signal of property
logicalDotsPerInchXᅟ
.- logicalDotsPerInchX()¶
- Return type:
float
Getter of property
logicalDotsPerInchXᅟ
.- logicalDotsPerInchY()¶
- Return type:
float
Getter of property
logicalDotsPerInchYᅟ
.- manufacturer()¶
- Return type:
str
Getter of property
manufacturerᅟ
.Maps the rect between two screen orientations.
This will flip the x and y dimensions of the rectangle
rect
if the orientationa
is Qt::PortraitOrientation or Qt::InvertedPortraitOrientation and orientationb
is Qt::LandscapeOrientation or Qt::InvertedLandscapeOrientation, or vice versa.Qt::PrimaryOrientation is interpreted as the screen’s
primaryOrientation()
.- model()¶
- Return type:
str
Getter of property
modelᅟ
.- name()¶
- Return type:
str
Getter of property
nameᅟ
.- nativeInterface()¶
- Return type:
object
- nativeOrientation()¶
- Return type:
Getter of property
nativeOrientationᅟ
.- orientation()¶
- Return type:
Getter of property
orientationᅟ
.- orientationChanged(orientation)¶
- Parameters:
orientation –
ScreenOrientation
This signal is emitted when the orientation of the screen changes with
orientation
as an argument.See also
Notification signal of property
orientationᅟ
.- physicalDotsPerInch()¶
- Return type:
float
Getter of property
physicalDotsPerInchᅟ
.- physicalDotsPerInchChanged(dpi)¶
- Parameters:
dpi – float
Notification signal of property
physicalDotsPerInchXᅟ
.- physicalDotsPerInchX()¶
- Return type:
float
Getter of property
physicalDotsPerInchXᅟ
.- physicalDotsPerInchY()¶
- Return type:
float
Getter of property
physicalDotsPerInchYᅟ
.Getter of property
physicalSizeᅟ
.Notification signal of property
physicalSizeᅟ
.- primaryOrientation()¶
- Return type:
Getter of property
primaryOrientationᅟ
.- primaryOrientationChanged(orientation)¶
- Parameters:
orientation –
ScreenOrientation
This signal is emitted when the primary orientation of the screen changes with
orientation
as an argument.See also
Notification signal of property
primaryOrientationᅟ
.- refreshRate()¶
- Return type:
float
Getter of property
refreshRateᅟ
.- refreshRateChanged(refreshRate)¶
- Parameters:
refreshRate – float
Notification signal of property
refreshRateᅟ
.- resolveInterface(name, revision)¶
- Parameters:
name – str
revision – int
- Return type:
void
- serialNumber()¶
- Return type:
str
Getter of property
serialNumberᅟ
.Getter of property
sizeᅟ
.Convenience function to compute a transform that maps from the coordinate system defined by orientation
a
into the coordinate system defined by orientationb
and target dimensionstarget
.Example,
a
is Qt::Landscape,b
is Qt::Portrait, andtarget
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).Qt::PrimaryOrientation is interpreted as the screen’s
primaryOrientation()
.Getter of property
virtualGeometryᅟ
.Notification signal of property
virtualSizeᅟ
.Returns the screen at
point
within the set ofvirtualSiblings()
, ornullptr
if outside of any screen.The
point
is in relation to thevirtualGeometry()
of each set of virtual siblings.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.
Getter of property
virtualSizeᅟ
.