MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9

QML Screen Element

Screen is a class that gives you physical information about the display of the device and its orientation. More...

This element was introduced in qt-components 4.7.

Properties

Detailed Description

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.

Property Documentation

allowSwipe : bool

MeeGo 1.2 Harmattan-specific property

Allows to switch off the swipe gesture. As a result the user won’t be able to close the application and he won't be able to push it to the background.

Caution: This feature should not be used unless there are very good reasons: The swipe gesture is an essential gesture that the user can rely on. Therefore switching it off is usually a bad idea.

In case of use (e.g. for games) please regard the following guidelines:

  • if the application shows a menu it should have the swipe enabled
  • only if the game is in "active" playing state the swipe gesture can be disabled or modified.
  • furthermore, applications that change the swipe behavior need to have a pause button: in pause mode the (swipe) gestures must be enabled.

allowedOrientations : enumeration

The allowed orientations for the screen. The property accepts any combination of Screen::Orientations flags.

  • Screen.Default - the default set of allowed orientations, may depend on hardware
  • Screen.Portrait - portrait mode allowed
  • Screen.Landscape - landscape mode allowed
  • Screen.PortraitInverted - inverted portrait mode allowed
  • Screen.LandscapeInverted - inverted landscape mode allowed
  • Screen.All - convenience enumeration for allowing all possible orientation modes

The property is 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.


covered : bool

MeeGo 1.2 Harmattan-specific property

Returns true if the screen is covered.


currentOrientation : enumeration

The current orientation of the screen. The possible values are:

  • Screen.Portrait - when the width of the screen is less than or equal to the height.
  • Screen.Landscape - when the width of the screen is greater than the height.
  • Screen.PortraitInverted - when the width of the screen is less than or equal to the height, and the screen is considered to be upside-down.
  • Screen.LandscapeInverted - when the width of the screen is greater than the height, and the screen is considered to be upside-down.

The actual possible values may depend on hardware. For instance, some devices support only one orientation, or some devices do 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.


density : enumeration

Screen classification based on the dpi value of the screen.

  • Screen.Low - a low-dpi screen
  • Screen.Medium - a medium-dpi screen
  • Screen.High - a high-dpi screen
  • Screen.ExtraHigh - an extra-high-dpi screen

Illustration of density mappings

See also displayCategory.


displayCategory : enumeration

Screen classification based on the physical size (diagonal) of the screen.

This property can be used for example for selecting different top level layouts for different display categories:

 Page {
     Loader {
         source: (screen.displayCategory == Screen.Small) ? "SmallView.qml" : "NormalView.qml"
         ...
     }
 }
  • Screen.Small - a small screen
  • Screen.Normal - a normal screen
  • Screen.Large - a large screen
  • Screen.ExtraLarge - an extra large screen

Illustration of displayCategory mappings

See also density.


displayHeight : int

The native height of the display in pixels, that is the height of the screen when rotation returns zero.

See also rotation.


displayWidth : int

The native width of the display in pixels, that is the width of the screen when rotation returns zero.

See also rotation.


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.


keyboardOpen : bool

MeeGo 1.2 Harmattan-specific property

Returns true if the virtual keyboard is shown on the screen.


minimized : bool

MeeGo 1.2 Harmattan-specific property

Returns true if the application is minimized to the switcher.


orientationString : string

MeeGo 1.2 Harmattan-specific property

Returns the current orientation as a String ("Portrait", "Landscape", "PortraitInverted" or "LandscapeInverted").


rotation : int

The rotation angle of the (logical content of the) screen, measured counter-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.


windowState : qvariant

MeeGo 1.2 Harmattan-specific property

An object giving various informations about the state of the windowState.

  • windowState.visible: returns true if the window or its thumbnail is shown; otherwise false if the window or its thumbnail has been hidden at least for 1000 ms.
  • windowState.active: returns true if the window is active (has focus).
  • windowState.animating: read-write property for the the window orientation animation.
  • windowState.viewMode: returns the current view mode, WindowState.Fullsize for fullscreen and WindowState.Thumbnail for thumbnail modes.
  • windowState.viewModeString: returns the current view mode as a string, "Fullsize" for fullsize and "Thumbnail" for thumbnail modes.