QScreen Class

  • Header: QScreen

  • Since: Qt 5.0

  • CMake:

    find_package(Qt6 REQUIRED COMPONENTS Gui)

    target_link_libraries(mytarget PRIVATE Qt6::Gui)

  • qmake: QT += gui

  • Inherits: QObject

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.

Both physical and logical DPI are expressed in device-independent dots. Multiply by QScreen::devicePixelRatio() to get device-dependent density.

Property Documentation

 

[read-only] 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:

  • availableGeometry() const

Notifier signal:

[read-only] 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:

  • availableSize() const

Notifier signal:

[read-only] 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:

  • availableVirtualGeometry() const

Notifier signal:

See Also

[read-only] 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:

  • availableVirtualSize() const

Notifier signal:

See Also

[read-only] depth : const int

This property holds the color depth of the screen

Access functions:

  • int depth() const

[read-only, since 5.5] 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:

  • devicePixelRatio() const

Notifier signal:

See Also

[read-only] 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:

  • geometry() const

Notifier signal:

[read-only] 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:

  • logicalDotsPerInch() const

Notifier signal:

See Also

[read-only] 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:

  • logicalDotsPerInchX() const

Notifier signal:

See Also

See also logicalDotsPerInchY()

[read-only] 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:

  • logicalDotsPerInchY() const

Notifier signal:

See Also

See also logicalDotsPerInchX()

[read-only, since 5.9] manufacturer : const QString

This property holds the manufacturer of the screen

This property was introduced in Qt 5.9.

Access functions:

  • manufacturer() const

[read-only, since 5.9] model : const QString

This property holds the model of the screen

This property was introduced in Qt 5.9.

Access functions:

  • model() const

[read-only] 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:

  • name() const

[read-only, since 5.2] 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:

  • nativeOrientation() const

[read-only] orientation : const 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.

Access functions:

  • orientation() const

Notifier signal:

See Also

[read-only] 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.

Physical DPI is expressed in device-independent dots. Multiply by QScreen::devicePixelRatio() to get device-dependent density.

Access functions:

  • physicalDotsPerInch() const

Notifier signal:

See Also

[read-only] 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.

Physical DPI is expressed in device-independent dots. Multiply by QScreen::devicePixelRatio() to get device-dependent density.

Access functions:

  • physicalDotsPerInchX() const

Notifier signal:

See Also

[read-only] 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.

Physical DPI is expressed in device-independent dots. Multiply by QScreen::devicePixelRatio() to get device-dependent density.

Access functions:

  • physicalDotsPerInchY() const

Notifier signal:

See Also

[read-only] 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:

  • physicalSize() const

Notifier signal:

  • void physicalSizeChanged(const &size)

[read-only] 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:

  • primaryOrientation() const

Notifier signal:

[read-only] refreshRate : const qreal

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

Avoid using the screen's refresh rate to drive animations via a timer such as QTimer. Instead use QWindow::requestUpdate().

Access functions:

  • refreshRate() const

Notifier signal:

  • void refreshRateChanged( refreshRate)

See Also

[read-only, since 5.9] serialNumber : const QString

This property holds the serial number of the screen

This property was introduced in Qt 5.9.

Access functions:

  • serialNumber() const

[read-only] size : const QSize

This property holds the pixel resolution of the screen

Access functions:

  • size() const

Notifier signal:

[read-only] 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:

  • virtualGeometry() const

Notifier signal:

See Also

See also virtualSiblings()

[read-only] 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:

  • virtualSize() const

Notifier signal:

See Also

See also