This class provides access to the screen properties, like the resolution, the orientation and the dpi.
Screen is exposed as a context property called "screen". It is not possible to instantiate a Screen object in QML, but the screen must be accessed through the context property.
TODO. This is a flags type property. Check that qdoc recognizes it correctly.
The allowed orientations for the screen. The property accepts any combination of Screen::Orientations flags.
The property can be used for locking the screen to a certain orientation, like this:
function lockToLandscape() { screen.allowedOrientation = Screen.Landscape }
Or it can be used for letting the orientation change freely according to the actual physical orientation of the device, like this:
function setAutomaticOrientation() { screen.allowedOrientation = Screen.All // equals to: // screen.allowedOrientation = Screen.Portrait | Screen.Landscape | // Screen.PortraitInverted | Screen.LandscapeInverted }
Notice that typically orientation is controlled by the Page component. This property should be used explicitly only if Page is not used at all, or if Page::orientationLock property is set to PageOrientation.Manual.
See also currentOrientation and Page::orientationLock.
The current orientation of the screen. The possible values are:
The actual possible values may depend on hardware. For instance, some devices might support only one orienation, or some devices might not support inverted orientations.
Notice that this is a read-only property. For setting the orientation use allowedProperties or Page::orientationLock
See also allowedOrientations and Page::orientationLock.
Screen classification based on the dpi value of the screen.
// TODO. How to document the limits of the categories if we do not want to expose the // accurate limits?
See also displayCategory.
Screen classification based on the physical size (diagonal) of the screen.
This property property can be used e.g. for selecting different top level layouts for different display categories:
Page { Loader { source: (screen.displayCategory == Screen.Small) ? "SmallView.qml" : "NormalView.qml" ... } }
// TODO. How to document the limits of the categories if we do not want to expose the // accurate limits?
See also density.
dpi : qreal |
The dots per inch value of the screen. It is assumed that the pixels are square, so in theory the value might not be 100% accurate.
Screen height in pixels. This value changes based on orientation, i.e. in portrait mode height is larger than width and in landscape mode vice versa.
See also displayHeight.
The rotation angle of the (logical content of the) screen, measured anti-clockwise relative to the native orientation of the device. If the rotation is zero it means that the screen is in the native orientation of the device.
The value is always non-negative. The actual possible values may depend on hardware.
See also displayWidth and displayHeight.
Screen width in pixels. This value changes based on orientation, i.e. in portrait mode width is smaller than height and in landscape mode vice versa.
See also displayWidth.