QScreen 類用於查詢屏幕特性。 更多...
| 頭: |
#include <QScreen>
|
| CMake: |
find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
|
| qmake: |
QT += gui
|
| 繼承: | QObject |
|
|
| 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 = 0, 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 |
| QNativeInterface * | nativeInterface () const |
| Qt::ScreenOrientation | nativeOrientation () const |
| Qt::ScreenOrientation | orientation () const |
| qreal | physicalDotsPerInch () const |
| qreal | physicalDotsPerInchX () const |
| qreal | physicalDotsPerInchY () const |
| QSizeF | physicalSize () const |
| Qt::ScreenOrientation | primaryOrientation () const |
| qreal | refreshRate () const |
| QString | serialNumber () const |
| QSize | size () const |
| QTransform | transformBetween (Qt::ScreenOrientation a , Qt::ScreenOrientation b , const QRect & target ) const |
| QRect | virtualGeometry () const |
| QScreen * | virtualSiblingAt (QPoint point ) |
| 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 ) |
注意邏輯點每英寸 vs 物理點每英寸:物理 DPI (點每英寸) 基於實際物理像素尺寸當可用時,且對打印預覽及其它期望知道屏幕顯示內容的精確物理維度的情況很有用。
邏輯點每英寸用於將字體和用戶界麵元素從點大小轉換為像素大小,且可能不同於物理點每英寸。邏輯點每英寸有時是用戶可在桌麵環境設置麵闆中設置的,以讓用戶全局控製不同應用程序的 UI 和字體大小。
注意: Both physical and logical DPI are expressed in device-independent dots. Multiply by QScreen::devicePixelRatio () to get device-dependent density.
[read-only]
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 ) |
[read-only]
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 ) |
[read-only]
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 ().
[read-only]
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 ().
[read-only]
depth
: const
int
此特性保持屏幕的顔色深度
訪問函數:
| int | depth () const |
[read-only]
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.
注意: On some platforms the devicePixelRatio of a window and the screen it is on can be different. Use this function only when you don't know which window you are targeting. If you do know the target window, use QWindow::devicePixelRatio () 代替。
訪問函數:
| qreal | devicePixelRatio () const |
通知程序信號:
| void | physicalDotsPerInchChanged (qreal dpi ) |
另請參閱 QWindow::devicePixelRatio () 和 QGuiApplication::devicePixelRatio ().
[read-only]
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 ) |
[read-only]
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 ().
[read-only]
logicalDotsPerInchX
: const
qreal
此特性保持水平方嚮的每英寸邏輯點數或像素數
This value is used to convert font point sizes to pixel sizes.
訪問函數:
| qreal | logicalDotsPerInchX () const |
通知程序信號:
| void | logicalDotsPerInchChanged (qreal dpi ) |
另請參閱 logicalDotsPerInchY ().
[read-only]
logicalDotsPerInchY
: const
qreal
此特性保持垂直方嚮的每英寸邏輯點數或像素數
This value is used to convert font point sizes to pixel sizes.
訪問函數:
| qreal | logicalDotsPerInchY () const |
通知程序信號:
| void | logicalDotsPerInchChanged (qreal dpi ) |
另請參閱 logicalDotsPerInchX ().
[read-only]
manufacturer
: const
QString
此特性保持屏幕的製造商
訪問函數:
| QString | 製造商 () const |
[read-only]
model
: const
QString
此特性保持屏幕的模型
訪問函數:
| QString | model () const |
[read-only]
name
: const
QString
此特性保持錶示屏幕的用戶可呈現字符串
For example, on X11 these correspond to the XRandr screen names, typically "VGA1", "HDMI1", etc.
注意: The user presentable string is not guaranteed to match the result of any native APIs, and should not be used to uniquely identify a screen.
訪問函數:
| QString | 名稱 () const |
[read-only]
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::ScreenOrientation | nativeOrientation () const |
[read-only]
orientation
: const
Qt::ScreenOrientation
此特性保持屏幕的取嚮
The
orientation
property tells the orientation of the screen from the window system perspective.
Most mobile devices and tablet computers contain accelerometer sensors. The Qt Sensors module provides the ability to read this sensor directly. However, the windowing system may rotate the entire screen automatically based on how it is being held; in that case, this
orientation
property will change.
訪問函數:
| Qt::ScreenOrientation | orientation () const |
通知程序信號:
| void | orientationChanged (Qt::ScreenOrientation orientation ) |
另請參閱 primaryOrientation () 和 QWindow::contentOrientation ().
[read-only]
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 特性。
注意: Physical DPI is expressed in device-independent dots. Multiply by QScreen::devicePixelRatio () to get device-dependent density.
訪問函數:
| qreal | physicalDotsPerInch () const |
通知程序信號:
| void | physicalDotsPerInchChanged (qreal dpi ) |
另請參閱 physicalDotsPerInchX () 和 physicalDotsPerInchY ().
[read-only]
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.
注意: Physical DPI is expressed in device-independent dots. Multiply by QScreen::devicePixelRatio () to get device-dependent density.
訪問函數:
| qreal | physicalDotsPerInchX () const |
通知程序信號:
| void | physicalDotsPerInchChanged (qreal dpi ) |
另請參閱 physicalDotsPerInchY ().
[read-only]
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.
注意: Physical DPI is expressed in device-independent dots. Multiply by QScreen::devicePixelRatio () to get device-dependent density.
訪問函數:
| qreal | physicalDotsPerInchY () const |
通知程序信號:
| void | physicalDotsPerInchChanged (qreal dpi ) |
另請參閱 physicalDotsPerInchX ().
[read-only]
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 ) |
[read-only]
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 ) |
[read-only]
refreshRate
: const
qreal
此特性保持屏幕的近似垂直刷新率 (以 Hz 為單位)
警告: Avoid using the screen's refresh rate to drive animations via a timer such as QChronoTimer . Instead use QWindow::requestUpdate ().
訪問函數:
| qreal | refreshRate () const |
通知程序信號:
| void | refreshRateChanged (qreal refreshRate ) |
另請參閱 QWindow::requestUpdate ().
[read-only]
serialNumber
: const
QString
此特性保持屏幕的序列號
訪問函數:
| QString | serialNumber () const |
[read-only]
size
: const
QSize
此特性保持屏幕的像素分辨率
訪問函數:
| QSize | size () const |
通知程序信號:
| void | geometryChanged (const QRect & geometry ) |
[read-only]
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 ().
[read-only]
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 ().
方便函數用於計算鏇轉角度獲取自鏇轉 a 到鏇轉 b .
結果會是 0、90、180 或 270。
Qt::PrimaryOrientation 被解釋成屏幕的 primaryOrientation ().
創建並返迴通過抓取內容構造的像素圖,為給定 window 限定通過 QRect ( x , y , width , height )。若 window 為 0,那麼將抓取整個屏幕。
自變量 ( 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 應該工作。
警告: 一般而言,抓住屏幕外區域是不安全的。這取決於底層窗口係統。
獲取平颱屏幕手柄。
另請參閱 QPA (Qt 平颱抽象) .
方便函數返迴
true
if
o
為橫嚮或倒置橫嚮;否則返迴
false
.
Qt::PrimaryOrientation 被解釋成屏幕的 primaryOrientation ().
方便函數返迴
true
if
o
為縱嚮或倒置縱嚮;否則返迴
false
.
Qt::PrimaryOrientation 被解釋成屏幕的 primaryOrientation ().
在 2 屏幕取嚮之間映射 rect 矩形。
這會翻轉 X 和 Y 維度對於矩形 rect 若取嚮 a is Qt::PortraitOrientation or Qt::InvertedPortraitOrientation 和取嚮 b is Qt::LandscapeOrientation or Qt::InvertedLandscapeOrientation ,反之亦然。
Qt::PrimaryOrientation 被解釋成屏幕的 primaryOrientation ().
Returns a native interface of the given type for the screen.
此函數提供對平颱特定功能的訪問為 QScreen ,作為定義在 QNativeInterface 名稱空間:
| Native interface to a screen | |
| Native interface to a screen on Wayland | |
| Native interface to a screen |
若請求接口不可用
nullptr
被返迴。
[signal]
void
QScreen::
orientationChanged
(
Qt::ScreenOrientation
orientation
)
此信號被發射當屏幕取嚮改變時,采用 orientation 作為自變量。
注意: 通知程序信號對於特性 orientation .
另請參閱 orientation ().
[signal]
void
QScreen::
primaryOrientationChanged
(
Qt::ScreenOrientation
orientation
)
此信號被發射當屏幕的首要取嚮改變采用 orientation 作為自變量。
注意: 通知程序信號對於特性 primaryOrientation .
另請參閱 primaryOrientation ().
方便函數用於計算變換映射坐標係定義按取嚮 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 ().
返迴的屏幕位於
point
within the set of
QScreen::virtualSiblings
(),或
nullptr
若在任何屏幕外。
The point is in relation to the virtualGeometry () of each set of virtual siblings.
獲取屏幕的虛擬同級。
虛擬同級是共享同一虛擬桌麵的屏幕實例。它們共享公共坐標係,且窗口可以在它們之間自由移動 (或定位) 而不必重新創建。