- Qt 6.8
- Qt Quick
- QML Types
- Screen
- Qt 6.8.1 Reference Documentation

# Screen QML Type

The Screen attached object provides information about the Screen an Item or Window is displayed on. More...

Import Statement: | `import QtQuick`

- List of all members, including inherited members
- Deprecated members

## Attached Properties

- desktopAvailableHeight : int
- desktopAvailableWidth : int
- devicePixelRatio : real
- height : int
- manufacturer : string
- model : string
- name : string
- orientation : Qt::ScreenOrientation
- pixelDensity : real
- primaryOrientation : Qt::ScreenOrientation
- serialNumber : string
- virtualX : int
- virtualY : int
- width : int

## Attached Methods

- int angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b)

## Detailed Description

The Screen attached object is valid inside Item or Item derived types, after component completion. Inside these items it refers to the screen that the item is currently being displayed on.

The attached object is also valid inside Window or Window derived types, after component completion. In that case it refers to the screen where the Window was created. It is generally better to access the Screen from the relevant Item instead, because on a multi-screen desktop computer, the user can drag a Window into a position where it spans across multiple screens. In that case some Items will be on one screen, and others on a different screen.

To use this type, you will need to import the module with the following line:

     import QtQuick.Window 2.2

It is a separate import in order to allow you to have a QML environment without access to window system features.

Note that the Screen type is not valid at Component.onCompleted, because the Item or Window has not been displayed on a screen by this time.

See also Qt Quick Examples - Window and Screen.

## Attached Property Documentation

Screen.desktopAvailableHeight : int `[read-only]`

This contains the available height of the collection of screens which make up the virtual desktop, in pixels, excluding window manager reserved areas such as task bars and system menus. If you want to position a Window at the bottom of the desktop, you can bind to it like this:

     y: Screen.desktopAvailableHeight - height

Screen.desktopAvailableWidth : int `[read-only]`

This contains the available width of the collection of screens which make up the virtual desktop, in pixels, excluding window manager reserved areas such as task bars and system menus. If you want to position a Window at the right of the desktop, you can bind to it like this:

     x: Screen.desktopAvailableWidth - width

Screen.devicePixelRatio : real `[read-only]`

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

Common values are 1.0 on normal displays and 2.0 on Apple "retina" displays.

Screen.height : int `[read-only]`

This contains the height of the screen in pixels.

Screen.manufacturer : string `[read-only]`

The manufacturer of the screen.

Screen.model : string `[read-only]`

The model of the screen.

Screen.name : string `[read-only]`

The name of the screen.

Screen.orientation : Qt::ScreenOrientation `[read-only]`

This contains the current orientation of the screen from the window system perspective.

Most mobile devices and tablet computers contain accelerometer sensors. The windowing system may rotate the entire screen automatically based on how it is being held, or manually via settings to rotate a desktop monitor; in that case, this `orientation` property will change.

See also primaryOrientation and QWindow::contentOrientation().

Screen.pixelDensity : real `[read-only]`

The number of physical pixels per millimeter.

Screen.primaryOrientation : Qt::ScreenOrientation `[read-only]`

This contains the primary orientation of the screen. If the screen's height is greater than its width, then the orientation is Qt.PortraitOrientation; otherwise it is Qt.LandscapeOrientation.

If you are designing an application which changes its layout depending on device orientation, you probably want to use primaryOrientation to determine the layout. That is because on a desktop computer, you can expect primaryOrientation to change when the user rotates the screen via the operating system's control panel, even if the computer does not contain an accelerometer. Likewise on most handheld computers which do have accelerometers, the operating system will rotate the whole screen automatically, so again you will see the primaryOrientation change.

Screen.serialNumber : string `[read-only]`

The serial number of the screen.

Screen.virtualX : int `[read-only]`

The x coordinate of the screen within the virtual desktop.

Screen.virtualY : int `[read-only]`

The y coordinate of the screen within the virtual desktop.

Screen.width : int `[read-only]`

This contains the width of the screen in pixels.

## Attached Method Documentation

int angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b)

Returns the rotation angle, in degrees, between the specified screen orientations a and b.