QScreen 類

The QScreen 類用於查詢屏幕特性。 更多...

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

特性

公共函數

virtual ~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 )

靜態公共成員

const QMetaObject staticMetaObject

額外繼承成員

詳細描述

The QScreen 類用於查詢屏幕特性。

注意邏輯點每英寸 vs 物理點每英寸:物理 DPI (點每英寸) 基於實際物理像素尺寸當可用時,且對打印預覽及其它期望知道屏幕顯示內容的精確物理維度的情況很有用。

邏輯點每英寸用於將字體和用戶界麵元素從點大小轉換為像素大小,且可能不同於物理點每英寸。邏輯點每英寸有時是用戶可在桌麵環境設置麵闆中設置的,以讓用戶全局控製不同應用程序的 UI 和字體大小。

特性文檔編製

availableGeometry : const QRect

此特性保持屏幕的可用幾何體 (以像素為單位)

可用幾何體是除窗口管理器預留區域 (譬如:任務欄和係統菜單) 外的幾何體。

Note, on X11 this will return the true available geometry only on systems with one monitor and if window manager has set _NET_WORKAREA atom. In all other cases this is equal to geometry (). This is a limitation in X11 window manager specification.

訪問函數:

QRect availableGeometry () const

通知程序信號:

void availableGeometryChanged (const QRect & geometry )

availableSize : const QSize

此特性保持屏幕的可用大小 (以像素為單位)

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 製造商 () 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

此特性保持屏幕的取嚮

屏幕取嚮錶示顯示的物理取嚮。例如,移動設備的屏幕取嚮將基於如何持有它改變。取嚮的改變可能觸發屏幕首要取嚮的改變,也可能不會。

此特性改變的過濾是通過 orientationUpdateMask (),所以,為接收取嚮更新,應用程序必須首先調用 setOrientationUpdateMask () 采用它想要接收的取嚮掩碼。

Qt::PrimaryOrientation 從不返迴。

訪問函數:

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 為負,函數將拷貝一切直到窗口底部。

偏移和尺寸自變量按設備無關像素數指定。返迴像素圖可能大於請求尺寸,當抓取高 DPI 屏幕時。調用 QPixmap::devicePixelRatio () 以確定是否是這種情況。

窗口係統標識符 ( 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 矩形。

這會翻轉 X 和 Y 維度對於矩形 rect 若取嚮 a is Qt::PortraitOrientation or Qt::InvertedPortraitOrientation 和取嚮 b is Qt::LandscapeOrientation or Qt::InvertedLandscapeOrientation ,反之亦然。

Qt::PrimaryOrientation 被解釋成屏幕的 primaryOrientation ().

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

此信號被發射當屏幕取嚮改變時,采用 orientation 作為自變量。

注意: 通知程序信號對於特性 orientation .

另請參閱 orientation ().

Qt::ScreenOrientations QScreen:: orientationUpdateMask () const

返迴目前設置的取嚮更新掩碼。

另請參閱 setOrientationUpdateMask ().

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

此信號被發射當屏幕的首要取嚮改變采用 orientation 作為自變量。

注意: 通知程序信號對於特性 primaryOrientation .

另請參閱 primaryOrientation ().

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

設置應用程序結閤此屏幕接收感興趣更新的取嚮。

例如,為接收 orientation () 更新且因此擁有 orientationChanged () 信號發射 LandscapeOrientation 和 InvertedLandscapeOrigination,調用 setOrientationUpdateMask() 將 mask 設為 Qt::LandscapeOrientation | Qt::InvertedLandscapeOrientation .

默認 0,意味著沒有 orientationChanged () 信號被激發。

另請參閱 orientationUpdateMask ().

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

方便函數用於計算變換映射坐標係定義按取嚮 a 到坐標係定義按取嚮 b 及目標維度 target .

範例, a 為 Qt::Landscape, b 為 Qt::Portrait,及 target is QRect (0, 0, w, h) 結果變換點 QPoint (0, 0) 被映射到 QPoint (0, w),和 QPoint (h, w) 被映射到 QPoint (0, h)。因此,橫嚮坐標係 QRect (0, 0, h, w) 被映射 (鏇轉90度) 到縱嚮坐標係 QRect (0, 0, w, h).

Qt::PrimaryOrientation 被解釋成屏幕的 primaryOrientation ().

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

獲取屏幕的虛擬同級。

虛擬同級是共享同一虛擬桌麵的屏幕實例。它們共享公共坐標係,且窗口可以在它們之間自由移動 (或定位) 而不必重新創建。