QScreen 类

QScreen class is used to query screen properties. 更多...

头: #include <QScreen>
qmake: QT += gui
Since: Qt 5.0
继承: QObject

特性

公共函数

~QScreen ()
int angleBetween (Qt::ScreenOrientation a , Qt::ScreenOrientation b ) const
QRect availableGeometry () const
QSize availableSize () const
QRect availableVirtualGeometry () const
QSize availableVirtualSize () const
int depth () const
qreal devicePixelRatio () const
QRect geometry () const
QPixmap grabWindow (WId window , int x = 0, int y = 0, int width = -1, int height = -1)
QPlatformScreen * handle () const
bool isLandscape (Qt::ScreenOrientation o ) const
bool isPortrait (Qt::ScreenOrientation o ) const
qreal logicalDotsPerInch () const
qreal logicalDotsPerInchX () const
qreal logicalDotsPerInchY () const
QString manufacturer () const
QRect mapBetween (Qt::ScreenOrientation a , Qt::ScreenOrientation b , const QRect & rect ) const
QString model () const
QString name () const
Qt::ScreenOrientation nativeOrientation () const
Qt::ScreenOrientation orientation () const
Qt::ScreenOrientations orientationUpdateMask () const
qreal physicalDotsPerInch () const
qreal physicalDotsPerInchX () const
qreal physicalDotsPerInchY () const
QSizeF physicalSize () const
Qt::ScreenOrientation primaryOrientation () const
qreal refreshRate () const
QString serialNumber () const
void setOrientationUpdateMask (Qt::ScreenOrientations mask )
QSize size () const
QTransform transformBetween (Qt::ScreenOrientation a , Qt::ScreenOrientation b , const QRect & target ) const
QRect virtualGeometry () const
QList<QScreen *> virtualSiblings () const
QSize virtualSize () const

信号

void availableGeometryChanged (const QRect & geometry )
void geometryChanged (const QRect & geometry )
void logicalDotsPerInchChanged (qreal dpi )
void orientationChanged (Qt::ScreenOrientation orientation )
void physicalDotsPerInchChanged (qreal dpi )
void physicalSizeChanged (const QSizeF & size )
void primaryOrientationChanged (Qt::ScreenOrientation orientation )
void refreshRateChanged (qreal refreshRate )
void virtualGeometryChanged (const QRect & rect )

额外继承成员

详细描述

QScreen class is used to query screen properties.

注意逻辑点每英寸 vs 物理点每英寸:物理 DPI (点每英寸) 基于实际物理像素尺寸当可用时,且对打印预览及其它期望知道屏幕显示内容的精确物理维度的情况很有用。

逻辑点每英寸用于将字体和用户界面元素从点大小转换为像素大小,且可能不同于物理点每英寸。逻辑点每英寸有时是用户可在桌面环境设置面板中设置的,以让用户全局控制不同应用程序的 UI 和字体大小。

特性文档编制

availableGeometry : const QRect

此特性保持屏幕的可用几何体 (以像素为单位)

The available geometry is the geometry excluding window manager reserved areas such as task bars and system menus.

访问函数:

QRect availableGeometry () const

通知程序信号:

void availableGeometryChanged (const QRect & geometry )

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.

访问函数:

QSize availableSize () const

通知程序信号:

void availableGeometryChanged (const QRect & geometry )

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.

访问函数:

QRect availableVirtualGeometry () const

通知程序信号:

void virtualGeometryChanged (const QRect & rect )

另请参阅 availableGeometry () 和 virtualSiblings ().

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.

访问函数:

QSize availableVirtualSize () const

通知程序信号:

void virtualGeometryChanged (const QRect & rect )

另请参阅 availableSize () 和 virtualSiblings ().

depth : const int

此特性保持屏幕的颜色深度

访问函数:

int depth () const

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.

该特性在 Qt 5.5 引入。

访问函数:

qreal devicePixelRatio () const

通知程序信号:

void physicalDotsPerInchChanged (qreal dpi )

另请参阅 QWindow::devicePixelRatio () 和 QGuiApplication::devicePixelRatio ().

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).

访问函数:

QRect geometry () const

通知程序信号:

void geometryChanged (const QRect & geometry )

logicalDotsPerInch : const qreal

此特性保持每英寸逻辑点数或像素数

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 特性。

访问函数:

qreal logicalDotsPerInch () const

通知程序信号:

void logicalDotsPerInchChanged (qreal dpi )

另请参阅 logicalDotsPerInchX () 和 logicalDotsPerInchY ().

logicalDotsPerInchX : const qreal

此特性保持水平方向的每英寸逻辑点数或像素数

This value is used to convert font point sizes to pixel sizes.

访问函数:

qreal logicalDotsPerInchX () const

通知程序信号:

void logicalDotsPerInchChanged (qreal dpi )

另请参阅 logicalDotsPerInchY ().

logicalDotsPerInchY : const qreal

此特性保持垂直方向的每英寸逻辑点数或像素数

This value is used to convert font point sizes to pixel sizes.

访问函数:

qreal logicalDotsPerInchY () const

通知程序信号:

void logicalDotsPerInchChanged (qreal dpi )

另请参阅 logicalDotsPerInchX ().

manufacturer : const QString

此特性保持屏幕的制造商

该特性在 Qt 5.9 引入。

访问函数:

QString manufacturer () const

model : const QString

此特性保持屏幕的模型

该特性在 Qt 5.9 引入。

访问函数:

QString model () const

name : const QString

此特性保持表示屏幕的用户可呈现字符串

For example, on X11 these correspond to the XRandr screen names, typically "VGA1", "HDMI1", etc.

访问函数:

QString name () const

nativeOrientation : const Qt::ScreenOrientation

此特性保持本机屏幕取向

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.

该特性在 Qt 5.2 引入。

访问函数:

Qt::ScreenOrientation nativeOrientation () const

orientation : const Qt::ScreenOrientation

此特性保持屏幕的取向

The screen orientation represents the physical orientation of the display. For example, the screen orientation of a mobile device will change based on how it is being held. A change to the orientation might or might not trigger a change to the primary orientation of the screen.

Changes to this property will be filtered by orientationUpdateMask (), so in order to receive orientation updates the application must first call setOrientationUpdateMask () with a mask of the orientations it wants to receive.

Qt::PrimaryOrientation is never returned.

访问函数:

Qt::ScreenOrientation orientation () const

通知程序信号:

void orientationChanged (Qt::ScreenOrientation orientation )

另请参阅 primaryOrientation ().

physicalDotsPerInch : const qreal

此特性保持每英寸的物理点数或像素数

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 特性。

访问函数:

qreal physicalDotsPerInch () const

通知程序信号:

void physicalDotsPerInchChanged (qreal dpi )

另请参阅 physicalDotsPerInchX () 和 physicalDotsPerInchY ().

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.

访问函数:

qreal physicalDotsPerInchX () const

通知程序信号:

void physicalDotsPerInchChanged (qreal dpi )

另请参阅 physicalDotsPerInchY ().

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.

访问函数:

qreal physicalDotsPerInchY () const

通知程序信号:

void physicalDotsPerInchChanged (qreal dpi )

另请参阅 physicalDotsPerInchX ().

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.

访问函数:

QSizeF physicalSize () const

通知程序信号:

void physicalSizeChanged (const QSizeF & size )

primaryOrientation : const Qt::ScreenOrientation

此特性保持首要屏幕取向

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.

访问函数:

Qt::ScreenOrientation primaryOrientation () const

通知程序信号:

void primaryOrientationChanged (Qt::ScreenOrientation orientation )

refreshRate : const qreal

此特性保持屏幕的近似垂直刷新率 (以 Hz 为单位)

访问函数:

qreal refreshRate () const

通知程序信号:

void refreshRateChanged (qreal refreshRate )

serialNumber : const QString

此特性保持屏幕的序列号

该特性在 Qt 5.9 引入。

访问函数:

QString serialNumber () const

size : const QSize

此特性保持屏幕的像素分辨率

访问函数:

QSize size () const

通知程序信号:

void geometryChanged (const QRect & geometry )

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.

访问函数:

QRect virtualGeometry () const

通知程序信号:

void virtualGeometryChanged (const QRect & rect )

另请参阅 virtualSiblings ().

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.

访问函数:

QSize virtualSize () const

通知程序信号:

void virtualGeometryChanged (const QRect & rect )

另请参阅 virtualSiblings ().

成员函数文档编制

QScreen:: ~QScreen ()

销毁屏幕。

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

方便函数能计算旋转角度以获取自旋转 a 到旋转 b .

结果会是 0、90、180 或 270。

Qt::PrimaryOrientation 被解释为屏幕的 primaryOrientation ().

QPixmap QScreen:: grabWindow ( WId window , int x = 0, int y = 0, int width = -1, int height = -1)

创建并返回通过抓取内容构造的像素图,为给定 window 限定通过 QRect ( x , y , width , height ).

自变量 ( x , y ) 指定窗口偏移,而 ( width , height ) 指定要拷贝的区域。若 width 为负,函数将拷贝一切直到窗口右边界。若 height 为负,函数将拷贝一切直到窗口底部。

窗口系统标识符 ( WId ) 可以检索使用 QWidget::winId () 函数。基本原理是使用窗口标识符而非 QWidget ,允许抓取不属于应用程序的窗口、窗口系统框架、等等。

警告: 抓取不属于应用程序的窗口在 iOS 系统不被支持,sandboxing/security 阻止读取应用程序不拥有的窗口像素。

grabWindow() 函数从屏幕而不是窗口抓取像素,即:若抓取的窗口之上有另一窗口的部分或全部,也会获取上面窗口的像素。通常,鼠标光标不被抓取。

注意:在 X11 若给定 window 没有如根窗口的相同深度,且另一窗口部分 (或完全) 遮盖抓取,将 not 获取上方窗口的像素。像素图遮盖区域的内容将是未定义和未初始化的。

在 Windows、Vista 及更高版本抓取分层窗口,创建通过设置 Qt::WA_TranslucentBackground 属性, 会不工作。相反,抓取桌面 Widget 应该工作。

警告: 一般而言,抓住屏幕外区域是不安全的。这取决于底层窗口系统。

QPlatformScreen *QScreen:: handle () const

获取平台屏幕手柄。

bool QScreen:: isLandscape ( Qt::ScreenOrientation o ) const

方便函数返回 true if o 为横向或倒置横向;否则返回 false .

Qt::PrimaryOrientation 被解释为屏幕的 primaryOrientation ().

bool QScreen:: isPortrait ( Qt::ScreenOrientation o ) const

方便函数返回 true if o 为纵向或倒置纵向;否则返回 false .

Qt::PrimaryOrientation 被解释为屏幕的 primaryOrientation ().

QRect QScreen:: mapBetween ( Qt::ScreenOrientation a , Qt::ScreenOrientation b , const QRect & rect ) const

在 2 屏幕取向之间映射 rect 矩形。

This will flip the x and y dimensions of the rectangle rect if the orientation a is Qt::PortraitOrientation or Qt::InvertedPortraitOrientation and orientation b is Qt::LandscapeOrientation or Qt::InvertedLandscapeOrientation , or vice versa.

Qt::PrimaryOrientation 被解释为屏幕的 primaryOrientation ().

[signal] void QScreen:: orientationChanged ( Qt::ScreenOrientation orientation )

此信号被发射当屏幕取向改变时,采用 orientation 作为自变量。

注意: 通知程序信号对于特性 orientation .

另请参阅 orientation ().

Qt::ScreenOrientations QScreen:: orientationUpdateMask () const

Returns the currently set orientation update mask.

另请参阅 setOrientationUpdateMask ().

[signal] void QScreen:: primaryOrientationChanged ( Qt::ScreenOrientation orientation )

This signal is emitted when the primary orientation of the screen changes with orientation 作为自变量。

注意: 通知程序信号对于特性 primaryOrientation .

另请参阅 primaryOrientation ().

void QScreen:: setOrientationUpdateMask ( Qt::ScreenOrientations mask )

Sets the orientations that the application is interested in receiving updates for in conjunction with this screen.

For example, to receive orientation () updates and thus have orientationChanged () signals being emitted for LandscapeOrientation and InvertedLandscapeOrientation, call setOrientationUpdateMask() with mask 设为 Qt::LandscapeOrientation | Qt::InvertedLandscapeOrientation .

The default, 0, means no orientationChanged () signals are fired.

另请参阅 orientationUpdateMask ().

QTransform QScreen:: transformBetween ( Qt::ScreenOrientation a , Qt::ScreenOrientation b , const QRect & target ) const

Convenience function to compute a transform that maps from the coordinate system defined by orientation a into the coordinate system defined by orientation b and target dimensions target .

范例, a is Qt::Landscape, b is Qt::Portrait, and target is QRect (0, 0, w, h) the resulting transform will be such that the point QPoint (0, 0) is mapped to QPoint (0, w), and QPoint (h, w) is mapped to QPoint (0, h). Thus, the landscape coordinate system QRect (0, 0, h, w) is mapped (with a 90 degree rotation) into the portrait coordinate system QRect (0, 0, w, h).

Qt::PrimaryOrientation 被解释为屏幕的 primaryOrientation ().

QList < QScreen *> QScreen:: virtualSiblings () const

获取屏幕的虚拟同级。

The virtual siblings are the screen instances sharing the same virtual desktop. They share a common coordinate system, and windows can freely be moved or positioned across them without having to be re-created.