QPlatformScreen Class

The QPlatformScreen class provides an abstraction for visual displays. More...

Header: #include <QPlatformScreen>

Public Functions

virtual int currentMode() const
virtual QPlatformCursor *cursor() const
virtual qreal devicePixelRatio() const
virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const
virtual QDpi logicalBaseDpi() const
virtual QDpi logicalDpi() const
virtual QString manufacturer() const
virtual QString model() const
virtual QList<Mode> modes() const
virtual Qt::ScreenOrientation nativeOrientation() const
virtual Qt::ScreenOrientation orientation() const
virtual QSizeF physicalSize() const
virtual PowerState powerState() const
virtual int preferredMode() const
virtual qreal refreshRate() const
const QPlatformScreen *screenForPosition(const QPoint &point) const
virtual QString serialNumber() const
virtual void setPowerState(PowerState state)
virtual SubpixelAntialiasingType subpixelAntialiasingTypeHint() const
virtual QWindow *topLevelAt(const QPoint &pos) const
virtual QList<QPlatformScreen *> virtualSiblings() const
QWindowList windows() const

Protected Functions

Detailed Description

\since4.8 \internal \preliminary \ingroup qpa

Many window systems has support for retrieving information on the attached displays. To be able to query the display QPA uses QPlatformScreen. Qt its self is most dependent on the physicalSize() function, since this is the function it uses to calculate the dpi to use when converting point sizes to pixels sizes. However, this is unfortunate on some systems, as the native system fakes its dpi size.

Member Function Documentation

[virtual] int QPlatformScreen::currentMode() const

Reimplement this function in subclass to return the index of the current mode from the modes list.

The default implementation returns 0.

\since5.9

See also QPlatformScreen::modes.

[virtual] QPlatformCursor *QPlatformScreen::cursor() const

Reimplement this function in subclass to return the cursor of the screen.

The default implementation returns nullptr.

[virtual] qreal QPlatformScreen::devicePixelRatio() const

Reimplement this function in subclass to return the device pixel ratio for the screen. This is the ratio between physical pixels and the device-independent pixels of the windowing system. The default implementation returns 1.0.

See also QPlatformWindow::devicePixelRatio().

[virtual] QPixmap QPlatformScreen::grabWindow(WId window, int x, int y, int width, int height) const

This function is called when Qt needs to be able to grab the content of a window.

Returns the content of the window specified with the WId handle within the boundaries of QRect(x,y,width,height).

[virtual] QDpi QPlatformScreen::logicalBaseDpi() const

Reimplement to return the base logical DPI for the platform. This DPI value should correspond to a standard-DPI (1x) display. The default implementation returns 96.

QtGui will use this value (together with logicalDpi) to compute the scale factor when high-DPI scaling is enabled, as follows: factor = logicalDPI / baseDPI

[virtual] QDpi QPlatformScreen::logicalDpi() const

Reimplement this function in subclass to return the logical horizontal and vertical dots per inch metrics of the screen.

The logical dots per inch metrics are used by Qt to scale the user interface.

The default implementation returns logicalBaseDpi(), which results in a UI scale factor of 1.0.

See also physicalSize.

[virtual] QString QPlatformScreen::manufacturer() const

Reimplement this function in subclass to return the manufacturer of this screen.

The default implementation returns an empty string.

\since5.9

[virtual] QString QPlatformScreen::model() const

Reimplement this function in subclass to return the model of this screen.

The default implementation returns an empty string.

\since5.9

[virtual] QList<Mode> QPlatformScreen::modes() const

Reimplement this function in subclass to return the list of modes for this screen.

The default implementation returns a list with only one mode from the current screen size and refresh rate.

\since5.9

See also QPlatformScreen::geometry and QPlatformScreen::refreshRate.

[virtual] Qt::ScreenOrientation QPlatformScreen::nativeOrientation() const

Reimplement this function in subclass to return the native orientation of the screen, e.g. the orientation where the logo sticker of the device appears the right way up.

The default implementation returns Qt::PrimaryOrientation.

[virtual] Qt::ScreenOrientation QPlatformScreen::orientation() const

Reimplement this function in subclass to return the current orientation of the screen, for example based on accelerometer data to determine the device orientation.

The default implementation returns Qt::PrimaryOrientation.

[virtual] QSizeF QPlatformScreen::physicalSize() const

Reimplement this function in subclass to return the physical size of the screen, in millimeters. The physical size represents the actual physical dimensions of the display.

The default implementation takes the pixel size of the screen, considers a resolution of 100 dots per inch, and returns the calculated physical size. A device with a screen that has different resolutions will need to be supported by a suitable reimplementation of this function.

See also logcalDpi.

[virtual] PowerState QPlatformScreen::powerState() const

Returns the current power state.

The default implementation always returns PowerStateOn.

See also setPowerState().

[virtual] int QPlatformScreen::preferredMode() const

Reimplement this function in subclass to return the preferred mode index from the modes list.

The default implementation returns 0.

\since5.9

See also QPlatformScreen::modes.

[virtual] qreal QPlatformScreen::refreshRate() const

Reimplement this function in subclass to return the vertical refresh rate of the screen, in Hz.

The default returns 60, a sensible default for modern displays.

[protected] void QPlatformScreen::resizeMaximizedWindows()

Convenience method to resize all the maximized and fullscreen windows of this platform screen.

const QPlatformScreen *QPlatformScreen::screenForPosition(const QPoint &point) const

Find the sibling screen corresponding to globalPos.

Returns this screen if no suitable screen is found at the position.

[virtual] QString QPlatformScreen::serialNumber() const

Reimplement this function in subclass to return the serial number of this screen.

The default implementation returns an empty string.

\since5.9

[virtual] void QPlatformScreen::setPowerState(PowerState state)

Sets the power state for this screen.

See also powerState().

[virtual] SubpixelAntialiasingType QPlatformScreen::subpixelAntialiasingTypeHint() const

Returns a hint about this screen's subpixel layout structure.

The default implementation queries the QT_SUBPIXEL_AA_TYPE env variable. This is just a hint because most platforms don't have a way to retrieve the correct value from hardware and instead rely on font configurations.

[virtual] QWindow *QPlatformScreen::topLevelAt(const QPoint &pos) const

Return the given top level window for a given position.

Default implementation retrieves a list of all top level windows and finds the first window which contains point pos

[virtual] QList<QPlatformScreen *> QPlatformScreen::virtualSiblings() const

Returns a list of all the platform screens that are part of the same virtual desktop.

Screens part of the same virtual desktop share a common coordinate system, and windows can be freely moved between them.

QWindowList QPlatformScreen::windows() const

Return all windows residing on this screen.