QScreen Class

The QScreen class is used to query screen properties. More...

Header: #include <QScreen>
qmake: QT += gui
Since: Qt 5.0
Inherits: QObject

This class was introduced in Qt 5.0.

Properties

Public Functions

QRect availableGeometry() const
QSize availableSize() const
QRect availableVirtualGeometry() const
QSize availableVirtualSize() const
int depth() const
qreal devicePixelRatio() const
QRect geometry() const
qreal logicalDotsPerInch() const
qreal logicalDotsPerInchX() const
qreal logicalDotsPerInchY() const
QString manufacturer() const
QString model() const
QString name() const
Qt::ScreenOrientation nativeOrientation() const
Qt::ScreenOrientation orientation() const
qreal physicalDotsPerInch() const
qreal physicalDotsPerInchX() const
qreal physicalDotsPerInchY() const
QSizeF physicalSize() const
Qt::ScreenOrientation primaryOrientation() const
qreal refreshRate() const
QString serialNumber() const
QSize size() const
QRect virtualGeometry() const
QSize virtualSize() const

Signals

void availableGeometryChanged(const QRect &geometry)
void geometryChanged(const QRect &geometry)
void logicalDotsPerInchChanged(qreal dpi)
void orientationChanged(Qt::ScreenOrientation orientation)
void physicalDotsPerInchChanged(qreal dpi)
void physicalSizeChanged(const QSizeF &size)
void primaryOrientationChanged(Qt::ScreenOrientation orientation)
void refreshRateChanged(qreal refreshRate)
void virtualGeometryChanged(const QRect &rect)

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.

Property Documentation

availableGeometry : const 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.

Access functions:

QRect availableGeometry() const

Notifier signal:

void availableGeometryChanged(const QRect &geometry)

availableSize : const 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.

Access functions:

QSize availableSize() const

Notifier signal:

void availableGeometryChanged(const QRect &geometry)

availableVirtualGeometry : const 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.

Access functions:

QRect availableVirtualGeometry() const

Notifier signal:

void virtualGeometryChanged(const QRect &rect)

See also availableGeometry() and virtualSiblings().

availableVirtualSize : const 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.

Access functions:

QSize availableVirtualSize() const

Notifier signal:

void virtualGeometryChanged(const QRect &rect)

See also availableSize() and virtualSiblings().

depth : const int

This property holds the color depth of the screen

Access functions:

int depth() const

devicePixelRatio : const qreal

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.

This property was introduced in Qt 5.5.

Access functions:

qreal devicePixelRatio() const

Notifier signal:

void physicalDotsPerInchChanged(qreal dpi)

See also QWindow::devicePixelRatio() and QGuiApplication::devicePixelRatio().

geometry : const 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).

Access functions:

QRect geometry() const

Notifier signal:

void geometryChanged(const QRect &geometry)

logicalDotsPerInch : const qreal

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.

Access functions:

qreal logicalDotsPerInch() const

Notifier signal:

void logicalDotsPerInchChanged(qreal dpi)

See also logicalDotsPerInchX() and logicalDotsPerInchY().

logicalDotsPerInchX : const qreal

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.

Access functions:

qreal logicalDotsPerInchX() const

Notifier signal:

void logicalDotsPerInchChanged(qreal dpi)

See also logicalDotsPerInchY().

logicalDotsPerInchY : const qreal

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.

Access functions:

qreal logicalDotsPerInchY() const

Notifier signal:

void logicalDotsPerInchChanged(qreal dpi)

See also logicalDotsPerInchX().

manufacturer : const QString

This property holds the manufacturer of the screen

This property was introduced in Qt 5.9.

Access functions:

QString manufacturer() const

model : const QString

This property holds the model of the screen

This property was introduced in Qt 5.9.

Access functions:

QString model() const

name : const QString

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.

Access functions:

QString name() const

nativeOrientation : const 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.

This property was introduced in Qt 5.2.

Access functions:

Qt::ScreenOrientation nativeOrientation() const

orientation : const Qt::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.

Qt::PrimaryOrientation is never returned.

Access functions:

Qt::ScreenOrientation orientation() const

Notifier signal:

void orientationChanged(Qt::ScreenOrientation orientation)

See also primaryOrientation().

physicalDotsPerInch : const qreal

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.

Access functions:

qreal physicalDotsPerInch() const

Notifier signal:

void physicalDotsPerInchChanged(qreal dpi)

See also physicalDotsPerInchX() and physicalDotsPerInchY().

physicalDotsPerInchX : const qreal

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.

Access functions:

qreal physicalDotsPerInchX() const

Notifier signal:

void physicalDotsPerInchChanged(qreal dpi)

See also physicalDotsPerInchY().

physicalDotsPerInchY : const qreal

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.

Access functions:

qreal physicalDotsPerInchY() const

Notifier signal:

void physicalDotsPerInchChanged(qreal dpi)

See also physicalDotsPerInchX().

physicalSize : const 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.

Access functions:

QSizeF physicalSize() const

Notifier signal:

void physicalSizeChanged(const QSizeF &size)

primaryOrientation : const 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:

Qt::ScreenOrientation primaryOrientation() const

Notifier signal:

void primaryOrientationChanged(Qt::ScreenOrientation orientation)

refreshRate : const qreal

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

Access functions:

qreal refreshRate() const

Notifier signal:

void refreshRateChanged(qreal refreshRate)

serialNumber : const QString

This property holds the serial number of the screen

This property was introduced in Qt 5.9.

Access functions:

QString serialNumber() const

size : const QSize

This property holds the pixel resolution of the screen

Access functions:

QSize size() const

Notifier signal:

void geometryChanged(const QRect &geometry)

virtualGeometry : const 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.

Access functions:

QRect virtualGeometry() const

Notifier signal:

void virtualGeometryChanged(const QRect &rect)

See also virtualSiblings().

virtualSize : const 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.

Access functions:

QSize virtualSize() const

Notifier signal:

void virtualGeometryChanged(const QRect &rect)

See also virtualSiblings().