头: | #include <QWindow> |
qmake: | QT += gui |
Since: | Qt 5.0 |
继承: | QObject and QSurface |
继承者: |
enum | AncestorMode { ExcludeTransients, IncludeTransients } |
enum | Visibility { Windowed, Minimized, Maximized, FullScreen, AutomaticVisibility, Hidden } |
|
QWindow (QScreen * targetScreen = Q_NULLPTR) | |
QWindow (QWindow * parent ) | |
virtual | ~QWindow () |
QSize | baseSize () const |
Qt::ScreenOrientation | contentOrientation () const |
void | create () |
QCursor | cursor () const |
void | destroy () |
qreal | devicePixelRatio () const |
QString | filePath () const |
Qt::WindowFlags | flags () const |
virtual QObject * | focusObject () const |
QRect | frameGeometry () const |
QMargins | frameMargins () const |
QPoint | framePosition () const |
QRect | geometry () const |
int | height () const |
QIcon | icon () const |
bool | isActive () const |
bool | isAncestorOf (const QWindow * child , AncestorMode mode = IncludeTransients) const |
bool | isExposed () const |
bool | isModal () const |
bool | isTopLevel () const |
bool | isVisible () const |
QPoint | mapFromGlobal (const QPoint & pos ) const |
QPoint | mapToGlobal (const QPoint & pos ) const |
QRegion | mask () const |
int | maximumHeight () const |
QSize | maximumSize () const |
int | maximumWidth () const |
int | minimumHeight () const |
QSize | minimumSize () const |
int | minimumWidth () const |
Qt::WindowModality | modality () const |
qreal | opacity () const |
QWindow * | parent (AncestorMode mode ) const |
QWindow * | parent () const |
QPoint | position () const |
void | reportContentOrientationChange (Qt::ScreenOrientation orientation ) |
QSurfaceFormat | requestedFormat () const |
void | resize (const QSize & newSize ) |
void | resize (int w , int h ) |
QScreen * | screen () const |
void | setBaseSize (const QSize & size ) |
void | setCursor (const QCursor & cursor ) |
void | setFilePath (const QString & filePath ) |
void | setFlag (Qt::WindowType flag , bool on = true) |
void | setFlags (Qt::WindowFlags flags ) |
void | setFormat (const QSurfaceFormat & format ) |
void | setFramePosition (const QPoint & point ) |
void | setGeometry (int posx , int posy , int w , int h ) |
void | setGeometry (const QRect & rect ) |
void | setIcon (const QIcon & icon ) |
bool | setKeyboardGrabEnabled (bool grab ) |
void | setMask (const QRegion & region ) |
void | setMaximumSize (const QSize & size ) |
void | setMinimumSize (const QSize & size ) |
void | setModality (Qt::WindowModality modality ) |
bool | setMouseGrabEnabled (bool grab ) |
void | setOpacity (qreal level ) |
void | setParent (QWindow * parent ) |
void | setPosition (const QPoint & pt ) |
void | setPosition (int posx , int posy ) |
void | setScreen (QScreen * newScreen ) |
void | setSizeIncrement (const QSize & size ) |
void | setSurfaceType (SurfaceType surfaceType ) |
void | setTransientParent (QWindow * parent ) |
void | setVisibility (Visibility v ) |
void | setWindowState (Qt::WindowState state ) |
QSize | sizeIncrement () const |
QString | title () const |
QWindow * | transientParent () const |
Qt::WindowType | type () const |
void | unsetCursor () |
Visibility | visibility () const |
int | width () const |
WId | winId () const |
Qt::WindowState | windowState () const |
int | x () const |
int | y () const |
virtual QSurfaceFormat | format () const |
virtual QSize | size () const |
virtual SurfaceType | surfaceType () const |
void | alert (int msec ) |
bool | close () |
void | hide () |
void | lower () |
void | raise () |
void | requestActivate () |
void | requestUpdate () |
void | setHeight (int arg ) |
void | setMaximumHeight (int h ) |
void | setMaximumWidth (int w ) |
void | setMinimumHeight (int h ) |
void | setMinimumWidth (int w ) |
void | setTitle ( const QString & ) |
void | setVisible (bool visible ) |
void | setWidth (int arg ) |
void | setX (int arg ) |
void | setY (int arg ) |
void | show () |
void | showFullScreen () |
void | showMaximized () |
void | showMinimized () |
void | showNormal () |
void | activeChanged () |
void | contentOrientationChanged (Qt::ScreenOrientation orientation ) |
void | focusObjectChanged (QObject * object ) |
void | heightChanged (int arg ) |
void | maximumHeightChanged (int arg ) |
void | maximumWidthChanged (int arg ) |
void | minimumHeightChanged (int arg ) |
void | minimumWidthChanged (int arg ) |
void | modalityChanged (Qt::WindowModality modality ) |
void | opacityChanged (qreal opacity ) |
void | screenChanged (QScreen * screen ) |
void | visibilityChanged (QWindow::Visibility visibility ) |
void | visibleChanged (bool arg ) |
void | widthChanged (int arg ) |
void | windowStateChanged (Qt::WindowState windowState ) |
void | windowTitleChanged (const QString & title ) |
void | xChanged (int arg ) |
void | yChanged (int arg ) |
QWindow * | fromWinId (WId id ) |
virtual void | exposeEvent (QExposeEvent * ev ) |
virtual void | focusInEvent (QFocusEvent * ev ) |
virtual void | focusOutEvent (QFocusEvent * ev ) |
virtual void | hideEvent (QHideEvent * ev ) |
virtual void | keyPressEvent (QKeyEvent * ev ) |
virtual void | keyReleaseEvent (QKeyEvent * ev ) |
virtual void | mouseDoubleClickEvent (QMouseEvent * ev ) |
virtual void | mouseMoveEvent (QMouseEvent * ev ) |
virtual void | mousePressEvent (QMouseEvent * ev ) |
virtual void | mouseReleaseEvent (QMouseEvent * ev ) |
virtual void | moveEvent (QMoveEvent * ev ) |
virtual bool | nativeEvent (const QByteArray & eventType , void * message , long * result ) |
virtual void | resizeEvent (QResizeEvent * ev ) |
virtual void | showEvent (QShowEvent * ev ) |
virtual void | tabletEvent (QTabletEvent * ev ) |
virtual void | touchEvent (QTouchEvent * ev ) |
virtual void | wheelEvent (QWheelEvent * ev ) |
virtual bool | event (QEvent * ev ) |
QWindow 类表示在底层窗口系统中的窗口。
由父级提供的窗口,将变为其父级窗口的本机子级窗口。
应用程序通常会使用 QWidget or QQuickView 为其 UI,而不是 QWindow 直接。仍然是可能的直接渲染到 QWindow with QBackingStore or QOpenGLContext ,当希望把依赖关系降到最低 (或想要直接使用 OpenGL) 时。 光栅窗口范例 and OpenGL 窗口范例 是有用参考范例为如何渲染到 QWindow 使用任一方式。
窗口可以潜在使用大量内存。通常度量是宽度乘以高度,乘以颜色深度。窗口还可能包括多个缓冲,以支持双缓冲和三缓冲,及深度和蜡纸缓冲。要释放窗口内存资源,调用 destroy () 函数。
QWindow has reportContentOrientationChange () that can be used to specify the layout of the window contents in relation to the screen. The content orientation is simply a hint to the windowing system about which orientation the window contents are in. It's useful when you wish to keep the same window size, but rotate the contents instead, especially when doing rotation animations between different orientations. The windowing system might use this value to determine the layout of system popups or dialogs.
By default, the window is not visible, and you must call setVisible (true), or show () or similar to make it visible. To make a window hidden again, call setVisible (false) or hide (). The visible property describes the state the application wants the window to be in. Depending on the underlying system, a visible window might still not be shown on the screen. It could, for instance, be covered by other opaque windows or moved outside the physical area of the screen. On windowing systems that have exposure notifications, the isExposed () accessor describes whether the window should be treated as directly visible on screen. The exposeEvent () function is called whenever the windows exposure in the windowing system changes. On windowing systems that do not make this information visible to the application, isExposed () will simply return the same value as isVisible ().
QWindow::Visibility queried through visibility () is a convenience API combining the functions of visible() and windowState ().
有 2 个 Qt API 可以用于将内容渲染到窗口, QBackingStore 渲染时采用 QPainter 并将内容刷新到窗口按类型 QSurface::RasterSurface ,和 QOpenGLContext 渲染采用 OpenGL 到窗口按类型 QSurface::OpenGLSurface .
The application can start rendering as soon as
isExposed
() 返回
true
, and can keep rendering until it
isExposed
() 返回
false
. To find out when
isExposed
() changes, reimplement
exposeEvent
(). The window will always get a resize event before the first expose event.
If the window's width and height are left uninitialized, the window will get a reasonable default geometry from the platform window. If the position is left uninitialized, then the platform window will allow the windowing system to position the window. For example on X11, the window manager usually does some kind of smart positioning to try to avoid having new windows completely obscure existing windows. However setGeometry () initializes both the position and the size, so if you want a fixed size but an automatic position, you should call resize () 或 setWidth () 和 setHeight () 代替。
This enum is used to control whether or not transient parents should be considered ancestors.
常量 | 值 | 描述 |
---|---|---|
QWindow::ExcludeTransients
|
0
|
Transient parents are not considered ancestors. |
QWindow::IncludeTransients
|
1
|
Transient parents are considered ancestors. |
This enum describes what part of the screen the window occupies or should occupy.
常量 | 值 | 描述 |
---|---|---|
QWindow::Windowed
|
2
|
The window occupies part of the screen, but not necessarily the entire screen. This state will occur only on windowing systems which support showing multiple windows simultaneously. In this state it is possible for the user to move and resize the window manually, if WindowFlags permit it and if it is supported by the windowing system. |
QWindow::Minimized
|
3
|
The window is reduced to an entry or icon on the task bar, dock, task list or desktop, depending on how the windowing system handles minimized windows. |
QWindow::Maximized
|
4
|
The window occupies one entire screen, and the titlebar is still visible. On most windowing systems this is the state achieved by clicking the maximize button on the toolbar. |
QWindow::FullScreen
|
5
|
The window occupies one entire screen, is not resizable, and there is no titlebar. On some platforms which do not support showing multiple simultaneous windows, this can be the usual visibility when the window is not hidden. |
QWindow::AutomaticVisibility
|
1
|
This means to give the window a default visible state, which might be fullscreen or windowed depending on the platform. It can be given as a parameter to setVisibility but will never be read back from the visibility accessor. |
QWindow::Hidden
|
0
|
The window is not visible in any way, however it may remember a latent visibility which can be restored by setting AutomaticVisibility. |
该枚举在 Qt 5.1 引入或被修改。
此特性保持窗口的活动状态
该特性在 Qt 5.1 引入。
访问函数:
bool | isActive () const |
通知程序信号:
void | activeChanged () |
另请参阅 requestActivate ().
此特性保持窗口内容的取向
This is a hint to the window manager in case it needs to display additional content like popups, dialogs, status bars, or similar in relation to the window.
推荐取向为 QScreen::orientation () but an application doesn't have to support all possible orientations, and thus can opt to ignore the current screen orientation.
The difference between the window and the content orientation determines how much to rotate the content by. QScreen::angleBetween (), QScreen::transformBetween (),和 QScreen::mapBetween () can be used to compute the necessary transform.
访问函数:
Qt::ScreenOrientation | contentOrientation () const |
void | reportContentOrientationChange (Qt::ScreenOrientation orientation ) |
通知程序信号:
void | contentOrientationChanged (Qt::ScreenOrientation orientation ) |
此特性保持窗口的窗口标志
The window flags control the window's appearance in the windowing system, whether it's a dialog, popup, or a regular window, and whether it should have a title bar, etc.
The actual window flags might differ from the flags set with setFlags() if the requested flags could not be fulfilled.
访问函数:
Qt::WindowFlags | flags () const |
void | setFlags (Qt::WindowFlags flags ) |
另请参阅 setFlag ().
此特性保持窗口几何体的高度
访问函数:
int | height () const |
void | setHeight (int arg ) |
通知程序信号:
void | heightChanged (int arg ) |
此特性保持窗口几何体的最大高度
访问函数:
int | maximumHeight () const |
void | setMaximumHeight (int h ) |
通知程序信号:
void | maximumHeightChanged (int arg ) |
This property holds the maximum width of the window's geometry
访问函数:
int | maximumWidth () const |
void | setMaximumWidth (int w ) |
通知程序信号:
void | maximumWidthChanged (int arg ) |
This property holds the minimum height of the window's geometry
访问函数:
int | minimumHeight () const |
void | setMinimumHeight (int h ) |
通知程序信号:
void | minimumHeightChanged (int arg ) |
This property holds the minimum width of the window's geometry
访问函数:
int | minimumWidth () const |
void | setMinimumWidth (int w ) |
通知程序信号:
void | minimumWidthChanged (int arg ) |
This property holds the modality of the window
A modal window prevents other windows from receiving input events. Qt supports two types of modality: Qt::WindowModal and Qt::ApplicationModal .
默认情况下此特性为 Qt::NonModal
访问函数:
Qt::WindowModality | modality () const |
void | setModality (Qt::WindowModality modality ) |
通知程序信号:
void | modalityChanged (Qt::WindowModality modality ) |
另请参阅 Qt::WindowModality .
此特性保持窗口系统中窗口的不透明度。
If the windowing system supports window opacity, this can be used to fade the window in and out, or to make it semitransparent.
A value of 1.0 or above is treated as fully opaque, whereas a value of 0.0 or below is treated as fully transparent. Values inbetween represent varying levels of translucency between the two extremes.
默认值为 1.0。
该特性在 Qt 5.1 引入。
访问函数:
qreal | opacity () const |
void | setOpacity (qreal level ) |
通知程序信号:
void | opacityChanged (qreal opacity ) |
This property holds the window's title in the windowing system
The window title might appear in the title area of the window decorations, depending on the windowing system and the window flags. It might also be used by the windowing system to identify the window in other contexts, such as in the task switcher.
访问函数:
QString | title () const |
void | setTitle ( const QString & ) |
通知程序信号:
void | windowTitleChanged (const QString & title ) |
另请参阅 flags ().
This property holds the screen-occupation state of the window
Visibility is whether the window should appear in the windowing system as normal, minimized, maximized, fullscreen or hidden.
To set the visibility to AutomaticVisibility means to give the window a default visible state, which might be fullscreen or windowed depending on the platform. When reading the visibility property you will always get the actual state, never AutomaticVisibility .
该特性在 Qt 5.1 引入。
访问函数:
Visibility | visibility () const |
void | setVisibility (Visibility v ) |
通知程序信号:
void | visibilityChanged (QWindow::Visibility visibility ) |
This property holds whether the window is visible or not
This property controls the visibility of the window in the windowing system.
By default, the window is not visible, you must call setVisible(true), or show () or similar to make it visible.
访问函数:
bool | isVisible () const |
void | setVisible (bool visible ) |
通知程序信号:
void | visibleChanged (bool arg ) |
另请参阅 show ().
This property holds the width of the window's geometry
访问函数:
int | width () const |
void | setWidth (int arg ) |
通知程序信号:
void | widthChanged (int arg ) |
This property holds the x position of the window's geometry
访问函数:
int | x () const |
void | setX (int arg ) |
通知程序信号:
void | xChanged (int arg ) |
This property holds the y position of the window's geometry
访问函数:
int | y () const |
void | setY (int arg ) |
通知程序信号:
void | yChanged (int arg ) |
创建顶层窗口,在 targetScreen .
窗口不被展示直到 setVisible (true), show (), or similar is called.
另请参阅 setScreen ().
创建窗口作为子级,为给定 parent 窗口。
窗口会被嵌入在父级窗口内,其坐标相对于父级。
屏幕继承自父级。
另请参阅 setParent ().
[virtual]
QWindow::
~QWindow
()
销毁窗口。
[slot]
void
QWindow::
alert
(
int
msec
)
Causes an alert to be shown for
msec
miliseconds. If
msec
is
0
(the default), then the alert is shown indefinitely until the window becomes active again. This function has no effect on an active window.
In alert state, the window indicates that it demands attention, for example by flashing or bouncing the taskbar entry.
该函数在 Qt 5.1 引入。
返回窗口的基尺寸。
另请参阅 setBaseSize ().
[slot]
bool
QWindow::
close
()
关闭窗口。
This closes the window, effectively calling
destroy
(), and potentially quitting the application. Returns
true
on success, false if it has a parent window (in which case the top level window should be closed instead).
另请参阅 destroy () 和 QGuiApplication::quitOnLastWindowClosed ().
Allocates the platform resources associated with the window.
It is at this point that the surface format set using setFormat () gets resolved into an actual native surface. However, the window remains hidden until setVisible () 被调用。
Note that it is not usually necessary to call this function directly, as it will be implicitly called by show (), setVisible (), and other functions that require access to the platform resources.
调用 destroy () to free the platform resources if necessary.
另请参阅 destroy ().
用于此窗口的光标形状
另请参阅 setCursor () 和 unsetCursor ().
释放关联此窗口的本机平台资源。
另请参阅 create ().
Returns the ratio between physical pixels and device-independent pixels for the window. This value is dependent on the screen the window is on, and may change when the window is moved.
Common values are 1.0 on normal displays and 2.0 on Apple "retina" displays.
注意: For windows not backed by a platform window, meaning that create () was not called, the function will fall back to the associated QScreen 's device pixel ratio.
另请参阅 QScreen::devicePixelRatio ().
[virtual protected]
bool
QWindow::
event
(
QEvent
*
ev
)
重实现自 QObject::event ().
Override this to handle any event (
ev
) sent to the window. Return
true
if the event was recognized and processed.
Remember to call the base class version if you wish for mouse events, key events, resize events, etc to be dispatched as usual.
[virtual protected]
void
QWindow::
exposeEvent
(
QExposeEvent
*
ev
)
曝光事件 ( ev ) is sent by the window system whenever the window's exposure on screen changes.
应用程序可以开始渲染到窗口,采用 QBackingStore and QOpenGLContext 一旦它获得 exposeEvent(),这样 isExposed () 为 true。
若窗口被移出屏幕,完全被另一窗口、图标化或类似窗口所遮盖,可能调用此函数,且值的 isExposed () 可能变为 false。当这发生时,应用程序应停止其渲染,因为它对用户不再可见。
Resize (重置尺寸) 事件将始终被发送,在窗口首次被展示的曝光事件之前。
另请参阅 isExposed ().
表示此窗口的文件名。
另请参阅 setFilePath ().
[virtual protected]
void
QWindow::
focusInEvent
(
QFocusEvent
*
ev
)
覆盖此以处理聚焦入事件 ( ev ).
Focus in events are sent when the window receives keyboard focus.
另请参阅 focusOutEvent ().
[virtual]
QObject
*QWindow::
focusObject
() const
返回 QObject that will be the final receiver of events tied focus, such as key events.
[signal]
void
QWindow::
focusObjectChanged
(
QObject
*
object
)
This signal is emitted when the final receiver of events tied to focus is changed to object .
另请参阅 focusObject ().
[virtual protected]
void
QWindow::
focusOutEvent
(
QFocusEvent
*
ev
)
覆盖此以处理聚焦出事件 ( ev ).
Focus out events are sent when the window loses keyboard focus.
另请参阅 focusInEvent ().
[virtual]
QSurfaceFormat
QWindow::
format
() const
重实现自 QSurface::format ().
Returns the actual format of this window.
After the window has been created, this function will return the actual surface format of the window. It might differ from the requested format if the requested format could not be fulfilled by the platform. It might also be a superset, for example certain buffer sizes may be larger than requested.
注意: Depending on the platform, certain values in this surface format may still contain the requested values, that is, the values that have been passed to setFormat (). Typical examples are the OpenGL version, profile and options. These may not get updated during create () since these are context specific and a single window may be used together with multiple contexts over its lifetime. Use the QOpenGLContext 's format() instead to query such values.
另请参阅 setFormat (), create (), requestedFormat (),和 QOpenGLContext::format ().
Returns the geometry of the window, including its window frame.
The geometry is in relation to the virtualGeometry() of its screen.
另请参阅 geometry () 和 frameMargins ().
Returns the window frame margins surrounding the window.
另请参阅 geometry () 和 frameGeometry ().
Returns the top left position of the window, including its window frame.
This returns the same value as frameGeometry (). topLeft ().
另请参阅 setFramePosition (), geometry (),和 frameGeometry ().
[static]
QWindow
*QWindow::
fromWinId
(
WId
id
)
创建由另一进程 (或由使用 Qt 下本机库) 创建的窗口的本地表示。
给定句柄 id 到本机窗口,此方法创建 QWindow 对象,其可以被用于表示窗口,当援引方法像 setParent () 和 setTransientParent ().
这可以在支持它的平台上使用,以嵌入 QWindow 在本机窗口,或把本机窗口嵌入在 QWindow .
若外来窗口不被支持,或在平台插件嵌入本地窗口失败,此函数返回 0。
注意: 结果 QWindow 不应用于操纵底层本机窗口 (除重新父级化外),或用于观察本机窗口的状态变化。对这类操作的任何支持都是偶然的,高度依赖平台且未经测试。
另请参阅 setParent () 和 setTransientParent ().
返回窗口几何体,不包括窗口框架。
The geometry is in relation to the virtualGeometry() of its screen.
另请参阅 setGeometry (), frameMargins (),和 frameGeometry ().
[slot]
void
QWindow::
hide
()
隐藏窗口。
相当于调用 setVisible (false).
另请参阅 show () 和 setVisible ().
[virtual protected]
void
QWindow::
hideEvent
(
QHideEvent
*
ev
)
覆写此以处理隐藏事件 ( ev ).
The function is called when the window has requested being hidden in the windowing system.
Sets the window's icon in the windowing system
另请参阅 setIcon ().
返回
true
if the window should appear active from a style perspective.
This is the case for the window that has input focus as well as windows that are in the same parent / transient parent chain as the focus window.
To get the window that currently has focus, use QGuiApplication::focusWindow ().
注意: Getter 函数对于特性 active .
返回
true
if the window is an ancestor of the given
child
。若
mode
is
IncludeTransients
, then transient parents are also considered ancestors.
Returns if this window is exposed in the windowing system.
When the window is not exposed, it is shown by the application but it is still not showing in the windowing system, so the application should minimize rendering and other graphical activities.
An exposeEvent () is sent every time this value changes.
另请参阅 exposeEvent ().
Returns whether the window is modal.
A modal window prevents other windows from getting any input.
另请参阅 QWindow::modality .
Returns whether the window is top level, i.e. has no parent window.
[virtual protected]
void
QWindow::
keyPressEvent
(
QKeyEvent
*
ev
)
Override this to handle key press events ( ev ).
另请参阅 keyReleaseEvent ().
[virtual protected]
void
QWindow::
keyReleaseEvent
(
QKeyEvent
*
ev
)
Override this to handle key release events ( ev ).
另请参阅 keyPressEvent ().
[slot]
void
QWindow::
lower
()
降低窗口系统中的窗口。
请求降低窗口将出现在其它窗口下方。
翻译全局屏幕坐标 pos to window coordinates.
另请参阅 mapToGlobal ().
Translates the window coordinate
pos
到全局屏幕坐标。例如:
mapToGlobal(QPoint(0,0))
would give the global coordinates of the top-left pixel of the window.
另请参阅 mapFromGlobal ().
Returns the mask set on the window.
The mask is a hint to the windowing system that the application does not want to receive mouse or touch input outside the given region.
另请参阅 setMask ().
Returns the maximum size of the window.
另请参阅 setMaximumSize ().
Returns the minimum size of the window.
另请参阅 setMinimumSize ().
[signal]
void
QWindow::
modalityChanged
(
Qt::WindowModality
modality
)
此信号被发射当 Qwindow::modality 特性变为 modality .
注意: 通知程序信号对于特性 modality .
[virtual protected]
void
QWindow::
mouseDoubleClickEvent
(
QMouseEvent
*
ev
)
Override this to handle mouse double click events ( ev ).
另请参阅 mousePressEvent () 和 QStyleHints::mouseDoubleClickInterval ().
[virtual protected]
void
QWindow::
mouseMoveEvent
(
QMouseEvent
*
ev
)
Override this to handle mouse move events ( ev ).
[virtual protected]
void
QWindow::
mousePressEvent
(
QMouseEvent
*
ev
)
Override this to handle mouse press events ( ev ).
另请参阅 mouseReleaseEvent ().
[virtual protected]
void
QWindow::
mouseReleaseEvent
(
QMouseEvent
*
ev
)
Override this to handle mouse release events ( ev ).
另请参阅 mousePressEvent ().
[virtual protected]
void
QWindow::
moveEvent
(
QMoveEvent
*
ev
)
Override this to handle window move events ( ev ).
[virtual protected]
bool
QWindow::
nativeEvent
(const
QByteArray
&
eventType
,
void
*
message
,
long
*
result
)
Override this to handle platform dependent events. Will be given eventType , message and result .
This might make your application non-portable.
Should return true only if the event was handled.
Returns the parent window, if any.
若 mode is IncludeTransients , then the transient parent is returned if there is no parent.
A window without a parent is known as a top level window.
该函数在 Qt 5.9 引入。
另请参阅 setParent ().
Returns the parent window, if any.
A window without a parent is known as a top level window.
Returns the position of the window on the desktop excluding any window frame
另请参阅 setPosition ().
[slot]
void
QWindow::
raise
()
在窗口系统中提升窗口。
请求提升窗口将出现在其它窗口上方。
[slot]
void
QWindow::
requestActivate
()
请求窗口被激活,即:接收键盘聚焦。
另请参阅 isActive (), QGuiApplication::focusWindow (),和 QWindowsWindowFunctions::setWindowActivationBehavior ().
[slot]
void
QWindow::
requestUpdate
()
调度 QEvent::UpdateRequest 事件以交付到此窗口。
The event is delivered in sync with the display vsync on platforms where this is possible. Otherwise, the event is delivered after a delay of 5 ms. The additional time is there to give the event loop a bit of idle time to gather system events, and can be overridden using the QT_QPA_UPDATE_IDLE_TIME environment variable.
When driving animations, this function should be called once after drawing has completed. Calling this function multiple times will result in a single event being delivered to the window.
子类化的 QWindow 应重实现 event (), intercept the event and call the application's rendering code, then call the base class implementation.
注意: The subclass' reimplementation of event () must invoke the base class implementation, unless it is absolutely sure that the event does not need to be handled by the base class. For example, the default implementation of this function relies on QEvent::Timer events. Filtering them away would therefore break the delivery of the update events.
该函数在 Qt 5.5 引入。
Returns the requested surface format of this window.
If the requested format was not supported by the platform implementation, the requestedFormat will differ from the actual window format.
This is the value set with setFormat ().
另请参阅 setFormat () 和 format ().
set the size of the window, excluding any window frame, to newSize
set the size of the window, excluding any window frame, to a QSize constructed from width w 和高度 h
[virtual protected]
void
QWindow::
resizeEvent
(
QResizeEvent
*
ev
)
Override this to handle resize events ( ev ).
The resize event is called whenever the window is resized in the windowing system, either directly through the windowing system acknowledging a setGeometry () 或 resize () request, or indirectly through the user resizing the window manually.
返回在其中展示窗口的屏幕,或 null 若没有的话。
对于子级窗口,这返回相应顶层窗口屏幕。
另请参阅 setScreen () 和 QScreen::virtualSiblings ().
[signal]
void
QWindow::
screenChanged
(
QScreen
*
screen
)
This signal is emitted when a window's screen 改变,通过明确设置采用 setScreen (), or automatically when the window's screen is removed.
Sets the base size 为窗口。
The base size is used to calculate a proper window size if the window defines sizeIncrement ().
另请参阅 setMinimumSize (), setMaximumSize (), setSizeIncrement (),和 baseSize ().
set the cursor shape for this window
The mouse cursor will assume this shape when it is over this window, unless an override cursor is set. See the 预定义光标对象列表 了解有用形状范围。
If no cursor has been set, or after a call to unsetCursor (), the parent window's cursor is used.
By default, the cursor has the Qt::ArrowCursor 形状。
Some underlying window implementations will reset the cursor if it leaves a window even if the mouse is grabbed. If you want to have a cursor set for all windows, even when outside the window, consider QGuiApplication::setOverrideCursor ().
另请参阅 cursor () 和 QGuiApplication::setOverrideCursor ().
set the file name this window is representing.
The windowing system might use filePath to display the path of the document this window is representing in the tile bar.
另请参阅 filePath ().
设置窗口标志 flag on this window if on 为 true;否则清零标志。
该函数在 Qt 5.9 引入。
另请参阅 setFlags (), flags (),和 type ().
Sets the window's surface format .
The format determines properties such as color depth, alpha, depth and stencil buffer size, etc. For example, to give a window a transparent background (provided that the window system supports compositing, and provided that other content in the window does not make it opaque again):
QSurfaceFormat format; format.setAlphaBufferSize(8); window.setFormat(format);
The surface format will be resolved in the create () function. Calling this function after create () has been called will not re-resolve the surface format of the native surface.
When the format is not explicitly set via this function, the format returned by QSurfaceFormat::defaultFormat () will be used. This means that when having multiple windows, individual calls to this function can be replaced by one single call to QSurfaceFormat::setDefaultFormat () before creating the first window.
另请参阅 format (), create (), destroy (),和 QSurfaceFormat::setDefaultFormat ().
Sets the upper left position of the window ( point ) including its window frame.
位置与其屏幕的 virtualGeometry() 有关。
另请参阅 framePosition (), setGeometry (),和 frameGeometry ().
Sets the geometry of the window, excluding its window frame, to a rectangle constructed from posx , posy , w and h .
The geometry is in relation to the virtualGeometry() of its screen.
另请参阅 geometry ().
Sets the geometry of the window, excluding its window frame, to rect .
The geometry is in relation to the virtualGeometry() of its screen.
另请参阅 geometry ().
Sets the window's icon in the windowing system
The window icon might be used by the windowing system for example to decorate the window, and/or in the task switcher.
另请参阅 icon ().
Sets whether keyboard grab should be enabled or not ( grab ).
If the return value is true, the window receives all key events until setKeyboardGrabEnabled(false) is called; other windows get no key events at all. Mouse events are not affected. Use setMouseGrabEnabled () 若想要抓取这。
另请参阅 setMouseGrabEnabled ().
Sets the mask of the window.
The mask is a hint to the windowing system that the application does not want to receive mouse or touch input outside the given region .
The window manager may or may not choose to display any areas of the window not included in the mask, thus it is the application's responsibility to clear to transparent the areas that are not part of the mask.
Setting the mask before the window has been created has no effect.
另请参阅 mask ().
Sets the maximum size of the window.
This is a hint to the window manager to prevent resizing above the specified size .
另请参阅 setMinimumSize () 和 maximumSize ().
Sets the minimum size of the window.
This is a hint to the window manager to prevent resizing below the specified size .
另请参阅 setMaximumSize () 和 minimumSize ().
Sets whether mouse grab should be enabled or not ( grab ).
If the return value is true, the window receives all mouse events until setMouseGrabEnabled(false) is called; other windows get no mouse events at all. Keyboard events are not affected. Use setKeyboardGrabEnabled () 若想要抓取这。
另请参阅 setKeyboardGrabEnabled ().
设置 parent 窗口。这将导致窗口系统管理窗口的裁剪,因此,它将被裁剪到 parent 窗口。
设置 parent 为 0 将使窗口变为顶层窗口。
若 parent 是窗口创建通过 fromWinId (),那么当前窗口将被嵌入在 parent ,若平台支持它。
另请参阅 parent ().
把窗口在桌面上的位置,设为 pt
位置与其屏幕的 virtualGeometry() 有关。
另请参阅 position ().
把窗口在桌面上的位置,设为 posx , posy
位置与其屏幕的 virtualGeometry() 有关。
另请参阅 position ().
Sets the screen on which the window should be shown.
If the window has been created, it will be recreated on the newScreen .
注意: 若屏幕是多屏幕虚拟桌面的一部分,窗口不会自动移至 newScreen . To place the window relative to the screen, use the screen's topLeft () position.
This function only works for top level windows.
另请参阅 screen () 和 QScreen::virtualSiblings ().
Sets the size increment ( size ) of the window.
When the user resizes the window, the size will move in steps of sizeIncrement (). width () pixels horizontally and sizeIncrement (). height () 像素垂直,采用 baseSize () as the basis.
默认情况下,此特性包含 0 大小宽度和高度。
窗口系统可能不支持大小增量。
另请参阅 sizeIncrement (), setBaseSize (), setMinimumSize (),和 setMaximumSize ().
设置 surfaceType 为窗口。
指定窗口为光栅渲染采用 QBackingStore ,或 OpenGL 渲染采用 QOpenGLContext .
surfaceType will be used when the native surface is created in the create () function. Calling this function after the native surface has been created requires calling destroy () 和 create () to release the old native surface and create a new one.
另请参阅 surfaceType (), QBackingStore , QOpenGLContext , create (),和 destroy ().
Sets the transient parent
This is a hint to the window manager that this window is a dialog or pop-up on behalf of the given window.
In order to cause the window to be centered above its transient parent by default, depending on the window manager, it may also be necessary to call
setFlags
() with a suitable
Qt::WindowType
(譬如
Qt::Dialog
).
另请参阅 transientParent () 和 parent ().
set the screen-occupation state of the window
The window state represents whether the window appears in the windowing system as maximized, minimized, fullscreen, or normal.
枚举值 Qt::WindowActive is not an accepted parameter.
另请参阅 windowState (), showNormal (), showFullScreen (), showMinimized (),和 showMaximized ().
[slot]
void
QWindow::
show
()
展示窗口。
这相当于调用 showFullScreen (), showMaximized (),或 showNormal (), depending on the platform's default behavior for the window type and flags.
另请参阅 showFullScreen (), showMaximized (), showNormal (), hide (), QStyleHints::showIsFullScreen (),和 flags ().
[virtual protected]
void
QWindow::
showEvent
(
QShowEvent
*
ev
)
覆写此以处理展示事件 ( ev ).
The function is called when the window has requested becoming visible.
If the window is successfully shown by the windowing system, this will be followed by a resize and an expose event.
[slot]
void
QWindow::
showFullScreen
()
以全屏方式展示窗口。
相当于调用 setWindowState ( Qt::WindowFullScreen ) 然后 setVisible (true)。
另请参阅 setWindowState () 和 setVisible ().
[slot]
void
QWindow::
showMaximized
()
Shows the window as maximized.
相当于调用 setWindowState ( Qt::WindowMaximized ) 然后 setVisible (true)。
另请参阅 setWindowState () 和 setVisible ().
[slot]
void
QWindow::
showMinimized
()
Shows the window as minimized.
相当于调用 setWindowState ( Qt::WindowMinimized ) 然后 setVisible (true)。
另请参阅 setWindowState () 和 setVisible ().
[slot]
void
QWindow::
showNormal
()
Shows the window as normal, i.e. neither maximized, minimized, nor fullscreen.
相当于调用 setWindowState ( Qt::WindowNoState ) 然后 setVisible (true)。
另请参阅 setWindowState () 和 setVisible ().
[virtual]
QSize
QWindow::
size
() const
重实现自 QSurface::size ().
Returns the size of the window excluding any window frame
另请参阅 resize ().
返回窗口的大小增量。
另请参阅 setSizeIncrement ().
[virtual]
SurfaceType
QWindow::
surfaceType
() const
重实现自 QSurface::surfaceType ().
返回窗口的表面类型。
另请参阅 setSurfaceType ().
[virtual protected]
void
QWindow::
tabletEvent
(
QTabletEvent
*
ev
)
Override this to handle tablet press, move, and release events ( ev ).
Proximity enter and leave events are not sent to windows, they are delivered to the application instance.
[virtual protected]
void
QWindow::
touchEvent
(
QTouchEvent
*
ev
)
Override this to handle touch events ( ev ).
Returns the transient parent of the window.
另请参阅 setTransientParent () 和 parent ().
返回窗口的类型。
This returns the part of the window flags that represents whether the window is a dialog, tooltip, popup, regular window, etc.
还原用于此窗口的默认箭头光标。
[virtual protected]
void
QWindow::
wheelEvent
(
QWheelEvent
*
ev
)
Override this to handle mouse wheel or other wheel events ( ev ).
返回窗口的平台 ID。
对于此 ID 可能有用的平台,返回值将表示相应屏幕内的唯一窗口。
另请参阅 screen ().
窗口的屏幕占用状态
另请参阅 setWindowState ().
[signal]
void
QWindow::
windowStateChanged
(
Qt::WindowState
windowState
)
此信号被发射当 windowState 改变,通过明确设置采用 setWindowState (),或自动当用户点击标题栏按钮之一或通过其它方式。