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.
访问函数:
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 | manufacturer () 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 | name () 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 QTimer . 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.
获取屏幕的虚拟同级。
虚拟同级是共享同一虚拟桌面的屏幕实例。它们共享公共坐标系,且窗口可以在它们之间自由移动 (或定位) 而不必重新创建。