QWindow Class
The QWindow class represents a window in the underlying windowing system. 更多...
公有类型
enum | AncestorMode { ExcludeTransients, IncludeTransients } |
enum | Visibility { Windowed, Minimized, Maximized, FullScreen, AutomaticVisibility, Hidden } |
属性
|
- 1 个属性继承自 QObject
公有函数
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 ®ion) |
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() |
- 1 个公有槽函数继承自 QObject
信号
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) |
- 2 个信号继承自 QObject
静态公有成员
QWindow * | fromWinId(WId id) |
- 10 个静态公有成员继承自 QObject
受保护的函数
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) |
- 9 个受保护的函数继承自 QObject
其他继承的成员
详细描述
QWindow 代表底层窗口系统中的一个窗口.
窗口支持父子关系, 它可以作为本地子窗口的父窗口.
应用程序的UI一般使用 QWidget 或 QQuickView, 而不是直接使用 QWindow. 当然, 如果你想将依赖关系降到最低或直接使用OpenGL, 那么, 你可以使用 QBackingStore 或 QOpenGLContext, 直接绘制到QWindow. Raster Window Example 和 OpenGL Window Example 示例展示如何使用QBackingStore 或 QOpenGLContext直接绘制到 QWindow.
资源管理
窗口可能使用大量内存. 常用的测量方法是宽度*高度*颜色深度. 窗口还可能包括多个缓冲区, 以便支持双重和三重缓冲, 及深度和模板缓存区. 调用 destroy() 释放窗口的内存资源.
内容定位
QWindow 具有 reportContentOrientationChange() , 指定窗口内容相对于屏幕的布局. 内容方向只是想窗口系统提示窗口内容的方向. 当你希望保持相同的窗口大小, 并旋转内容时, 这很有用, 尤其是在不同方向旋转动画. 窗口系统可能使用这个值确定系统弹出框或对话框的布局.
可见性和窗口系统显示
默认情况下, 窗口不可见, 你必须调用 setVisible(true), 或 show(), 或相似的可见函数. 若想再次隐藏窗口, 调用 setVisible(false) 或 hide(). visible属性描述应用程序期望窗口处于的状态. 根据底层系统的不同, 显示状态的窗口仍可能不会显示在屏幕上. 例如, 它可能被其他窗口覆盖, 或移动到屏幕外. 在具有显示通知的窗口系统上, isExposed() 返回窗口是否在屏幕上直接可见. 只要窗口的某个区域无效, 就会调用 exposeEvent() 函数. 如, 窗口系统显示发生变化. 在应用程序看不到这些信息的窗口系统上, isExposed() 返回与 isVisible()相同的值.
调用QWindow::Visibility 查询 visibility() 属性, 它结合 visible() 和 windowState()函数.
渲染
Qt提供两类API, 将内容直接渲染到窗口. QBackingStore 使用 QPainter 渲染, 并将内容刷新到类型是 QSurface::RasterSurface的窗口, QOpenGLContext 使用OpenGL渲染到类型是 QSurface::OpenGLSurface的窗口.
isExposed() 返回 true
, 应用程序开始渲染, 直到 isExposed() 返回 false
, 才结束渲染. 重新实现 exposeEvent(), 可以知道isExposed()何时改变. 窗口始终在第一个exposeEvent前得到一个resizeEvent.
初始化几何尺寸
如果窗口的宽度和高度未初始化, 则窗口将从平台窗口获得合理的默认几何尺寸. 如果位置未初始化, 则平台窗口将允许窗口系统计算窗口位置. 例如, 在X11上, 窗口管理器通常会进行某种智能定位, 避免新窗口完全遮挡现有窗口. 然而, setGeometry() 会初始化位置和大小, 因此如果你想要一个大小固定, 位置自动的窗口, 则应该调用 resize() 或 setWidth() 和 setHeight().
成员类型
enum QWindow::AncestorMode
This enum is used to control whether or not transient parents should be considered ancestors.
Constant | Value | Description |
---|---|---|
QWindow::ExcludeTransients | 0 | Transient parents are not considered ancestors. |
QWindow::IncludeTransients | 1 | Transient parents are considered ancestors. |
enum QWindow::Visibility
This enum describes what part of the screen the window occupies or should occupy.
Constant | Value | Description |
---|---|---|
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. |
This enum was introduced or modified in Qt 5.1.
属性
active : const bool
This property holds the active status of the window
This property was introduced in Qt 5.1.
访问函数:
bool | isActive() const |
Notifier signal:
void | activeChanged() |
参见 requestActivate().
contentOrientation : Qt::ScreenOrientation
This property holds the orientation of the window's contents
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.
The recommended orientation is 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(), and QScreen::mapBetween() can be used to compute the necessary transform.
The default value is Qt::PrimaryOrientation
访问函数:
Qt::ScreenOrientation | contentOrientation() const |
void | reportContentOrientationChange(Qt::ScreenOrientation orientation) |
Notifier signal:
void | contentOrientationChanged(Qt::ScreenOrientation orientation) |
flags : Qt::WindowFlags
This property holds the window flags of the window
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().
height : int
This property holds the height of the window's geometry
访问函数:
int | height() const |
void | setHeight(int arg) |
Notifier signal:
void | heightChanged(int arg) |
maximumHeight : int
This property holds the maximum height of the window's geometry
访问函数:
int | maximumHeight() const |
void | setMaximumHeight(int h) |
Notifier signal:
void | maximumHeightChanged(int arg) |
maximumWidth : int
This property holds the maximum width of the window's geometry
访问函数:
int | maximumWidth() const |
void | setMaximumWidth(int w) |
Notifier signal:
void | maximumWidthChanged(int arg) |
minimumHeight : int
This property holds the minimum height of the window's geometry
访问函数:
int | minimumHeight() const |
void | setMinimumHeight(int h) |
Notifier signal:
void | minimumHeightChanged(int arg) |
minimumWidth : int
This property holds the minimum width of the window's geometry
访问函数:
int | minimumWidth() const |
void | setMinimumWidth(int w) |
Notifier signal:
void | minimumWidthChanged(int arg) |
modality : Qt::WindowModality
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.
By default, this property is Qt::NonModal
访问函数:
Qt::WindowModality | modality() const |
void | setModality(Qt::WindowModality modality) |
Notifier signal:
void | modalityChanged(Qt::WindowModality modality) |
opacity : qreal
This property holds the opacity of the window in the windowing system.
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.
The default value is 1.0.
This property was introduced in Qt 5.1.
访问函数:
qreal | opacity() const |
void | setOpacity(qreal level) |
Notifier signal:
void | opacityChanged(qreal opacity) |
title : QString
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 &) |
Notifier signal:
void | windowTitleChanged(const QString &title) |
参见 flags().
visibility : Visibility
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.
This property was introduced in Qt 5.1.
访问函数:
Visibility | visibility() const |
void | setVisibility(Visibility v) |
Notifier signal:
void | visibilityChanged(QWindow::Visibility visibility) |
visible : bool
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) |
Notifier signal:
void | visibleChanged(bool arg) |
参见 show().
width : int
This property holds the width of the window's geometry
访问函数:
int | width() const |
void | setWidth(int arg) |
Notifier signal:
void | widthChanged(int arg) |
x : int
This property holds the x position of the window's geometry
访问函数:
int | x() const |
void | setX(int arg) |
Notifier signal:
void | xChanged(int arg) |
y : int
This property holds the y position of the window's geometry
访问函数:
int | y() const |
void | setY(int arg) |
Notifier signal:
void | yChanged(int arg) |
成员函数
QWindow::QWindow(QScreen *targetScreen = Q_NULLPTR)
Creates a window as a top level on the targetScreen.
The window is not shown until setVisible(true), show(), or similar is called.
参见 setScreen().
QWindow::QWindow(QWindow *parent)
Creates a window as a child of the given parent window.
The window will be embedded inside the parent window, its coordinates relative to the parent.
The screen is inherited from the parent.
参见 setParent().
[virtual]
QWindow::~QWindow()
Destroys the window.
[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.
This function was introduced in Qt 5.1.
QSize QWindow::baseSize() const
Returns the base size of the window.
参见 setBaseSize().
[slot]
bool QWindow::close()
Close the window.
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() and QGuiApplication::quitOnLastWindowClosed().
void QWindow::create()
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() is called.
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.
Call destroy() to free the platform resources if necessary.
参见 destroy().
QCursor QWindow::cursor() const
the cursor shape for this window
参见 setCursor() and unsetCursor().
void QWindow::destroy()
Releases the native platform resources associated with this window.
参见 create().
qreal QWindow::devicePixelRatio() const
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.
Note: 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)
Reimplemented from 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)
The expose event (ev) is sent by the window system whenever the window's exposure on screen changes.
The application can start rendering into the window with QBackingStore and QOpenGLContext as soon as it gets an exposeEvent() such that isExposed() is true.
If the window is moved off screen, is made totally obscured by another window, iconified or similar, this function might be called and the value of isExposed() might change to false. When this happens, an application should stop its rendering as it is no longer visible to the user.
A resize event will always be sent before the expose event the first time a window is shown.
参见 isExposed().
QString QWindow::filePath() const
the file name this window is representing.
参见 setFilePath().
[virtual protected]
void QWindow::focusInEvent(QFocusEvent *ev)
Override this to handle focus in events (ev).
Focus in events are sent when the window receives keyboard focus.
参见 focusOutEvent().
[virtual]
QObject *QWindow::focusObject() const
Returns the 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)
Override this to handle focus out events (ev).
Focus out events are sent when the window loses keyboard focus.
参见 focusInEvent().
[virtual]
QSurfaceFormat QWindow::format() const
Reimplemented from 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.
Note: 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(), and QOpenGLContext::format().
QRect QWindow::frameGeometry() const
Returns the geometry of the window, including its window frame.
The geometry is in relation to the virtualGeometry() of its screen.
参见 geometry() and frameMargins().
QMargins QWindow::frameMargins() const
Returns the window frame margins surrounding the window.
参见 geometry() and frameGeometry().
QPoint QWindow::framePosition() const
Returns the top left position of the window, including its window frame.
This returns the same value as frameGeometry().topLeft().
参见 setFramePosition(), geometry(), and frameGeometry().
[static]
QWindow *QWindow::fromWinId(WId id)
Creates a local representation of a window created by another process or by using native libraries below Qt.
Given the handle id to a native window, this method creates a QWindow object which can be used to represent the window when invoking methods like setParent() and setTransientParent().
This can be used, on platforms which support it, to embed a QWindow inside a native window, or to embed a native window inside a QWindow.
If foreign windows are not supported or embedding the native window failed in the platform plugin, this function returns 0.
Note: The resulting QWindow should not be used to manipulate the underlying native window (besides re-parenting), or to observe state changes of the native window. Any support for these kind of operations is incidental, highly platform dependent and untested.
参见 setParent() and setTransientParent().
QRect QWindow::geometry() const
Returns the geometry of the window, excluding its window frame.
The geometry is in relation to the virtualGeometry() of its screen.
参见 setGeometry(), frameMargins(), and frameGeometry().
[slot]
void QWindow::hide()
Hides the window.
Equivalent to calling setVisible(false).
参见 show() and setVisible().
[virtual protected]
void QWindow::hideEvent(QHideEvent *ev)
Override this to handle hide events (ev).
The function is called when the window has requested being hidden in the windowing system.
QIcon QWindow::icon() const
Sets the window's icon in the windowing system
参见 setIcon().
bool QWindow::isActive() const
Returns 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().
Note: Getter function for property active.
bool QWindow::isAncestorOf(const QWindow *child, AncestorMode mode = IncludeTransients) const
Returns true
if the window is an ancestor of the given child. If mode is IncludeTransients, then transient parents are also considered ancestors.
bool QWindow::isExposed() const
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().
bool QWindow::isModal() const
Returns whether the window is modal.
A modal window prevents other windows from getting any input.
bool QWindow::isTopLevel() const
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()
Lower the window in the windowing system.
Requests that the window be lowered to appear below other windows.
QPoint QWindow::mapFromGlobal(const QPoint &pos) const
Translates the global screen coordinate pos to window coordinates.
参见 mapToGlobal().
QPoint QWindow::mapToGlobal(const QPoint &pos) const
Translates the window coordinate pos to global screen coordinates. For example, mapToGlobal(QPoint(0,0))
would give the global coordinates of the top-left pixel of the window.
参见 mapFromGlobal().
QRegion QWindow::mask() const
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().
QSize QWindow::maximumSize() const
Returns the maximum size of the window.
参见 setMaximumSize().
QSize QWindow::minimumSize() const
Returns the minimum size of the window.
参见 setMinimumSize().
[signal]
void QWindow::modalityChanged(Qt::WindowModality modality)
This signal is emitted when the Qwindow::modality property changes to modality.
Note: Notifier signal for property modality.
[virtual protected]
void QWindow::mouseDoubleClickEvent(QMouseEvent *ev)
Override this to handle mouse double click events (ev).
参见 mousePressEvent() and 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.
QWindow *QWindow::parent(AncestorMode mode) const
Returns the parent window, if any.
If 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.
This function was introduced in Qt 5.9.
参见 setParent().
QWindow *QWindow::parent() const
Returns the parent window, if any.
A window without a parent is known as a top level window.
QPoint QWindow::position() const
Returns the position of the window on the desktop excluding any window frame
参见 setPosition().
[slot]
void QWindow::raise()
Raise the window in the windowing system.
Requests that the window be raised to appear above other windows.
[slot]
void QWindow::requestActivate()
Requests the window to be activated, i.e. receive keyboard focus.
参见 isActive(), QGuiApplication::focusWindow(), and QWindowsWindowFunctions::setWindowActivationBehavior().
[slot]
void QWindow::requestUpdate()
Schedules a QEvent::UpdateRequest event to be delivered to this window.
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.
Subclasses of QWindow should reimplement event(), intercept the event and call the application's rendering code, then call the base class implementation.
Note: 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.
This function was introduced in Qt 5.5.
QSurfaceFormat QWindow::requestedFormat() const
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().
void QWindow::resize(const QSize &newSize)
set the size of the window, excluding any window frame, to newSize
void QWindow::resize(int w, int h)
set the size of the window, excluding any window frame, to a QSize constructed from width w and height 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() or resize() request, or indirectly through the user resizing the window manually.
QScreen *QWindow::screen() const
Returns the screen on which the window is shown, or null if there is none.
For child windows, this returns the screen of the corresponding top level window.
参见 setScreen() and QScreen::virtualSiblings().
[signal]
void QWindow::screenChanged(QScreen *screen)
This signal is emitted when a window's screen changes, either by being set explicitly with setScreen(), or automatically when the window's screen is removed.
void QWindow::setBaseSize(const QSize &size)
Sets the base size of the window.
The base size is used to calculate a proper window size if the window defines sizeIncrement().
参见 setMinimumSize(), setMaximumSize(), setSizeIncrement(), and baseSize().
void QWindow::setCursor(const QCursor &cursor)
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 list of predefined cursor objects for a range of useful shapes.
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 shape.
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() and QGuiApplication::setOverrideCursor().
void QWindow::setFilePath(const QString &filePath)
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().
void QWindow::setFlag(Qt::WindowType flag, bool on = true)
Sets the window flag flag on this window if on is true; otherwise clears the flag.
This function was introduced in Qt 5.9.
参见 setFlags(), flags(), and type().
void QWindow::setFormat(const QSurfaceFormat &format)
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(), and QSurfaceFormat::setDefaultFormat().
void QWindow::setFramePosition(const QPoint &point)
Sets the upper left position of the window (point) including its window frame.
The position is in relation to the virtualGeometry() of its screen.
参见 framePosition(), setGeometry(), and frameGeometry().
void QWindow::setGeometry(int posx, int posy, int w, int h)
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().
void QWindow::setGeometry(const QRect &rect)
Sets the geometry of the window, excluding its window frame, to rect.
The geometry is in relation to the virtualGeometry() of its screen.
参见 geometry().
void QWindow::setIcon(const QIcon &icon)
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().
bool QWindow::setKeyboardGrabEnabled(bool grab)
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() if you want to grab that.
参见 setMouseGrabEnabled().
void QWindow::setMask(const QRegion ®ion)
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().
void QWindow::setMaximumSize(const QSize &size)
Sets the maximum size of the window.
This is a hint to the window manager to prevent resizing above the specified size.
参见 setMinimumSize() and maximumSize().
void QWindow::setMinimumSize(const QSize &size)
Sets the minimum size of the window.
This is a hint to the window manager to prevent resizing below the specified size.
参见 setMaximumSize() and minimumSize().
bool QWindow::setMouseGrabEnabled(bool grab)
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() if you want to grab that.
参见 setKeyboardGrabEnabled().
void QWindow::setParent(QWindow *parent)
Sets the parent Window. This will lead to the windowing system managing the clip of the window, so it will be clipped to the parent window.
Setting parent to be 0 will make the window become a top level window.
If parent is a window created by fromWinId(), then the current window will be embedded inside parent, if the platform supports it.
参见 parent().
void QWindow::setPosition(const QPoint &pt)
set the position of the window on the desktop to pt
The position is in relation to the virtualGeometry() of its screen.
参见 position().
void QWindow::setPosition(int posx, int posy)
set the position of the window on the desktop to posx, posy
The position is in relation to the virtualGeometry() of its screen.
参见 position().
void QWindow::setScreen(QScreen *newScreen)
Sets the screen on which the window should be shown.
If the window has been created, it will be recreated on the newScreen.
Note: If the screen is part of a virtual desktop of multiple screens, the window will not move automatically to newScreen. To place the window relative to the screen, use the screen's topLeft() position.
This function only works for top level windows.
参见 screen() and QScreen::virtualSiblings().
void QWindow::setSizeIncrement(const QSize &size)
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() pixels vertically, with baseSize() as the basis.
By default, this property contains a size with zero width and height.
The windowing system might not support size increments.
参见 sizeIncrement(), setBaseSize(), setMinimumSize(), and setMaximumSize().
void QWindow::setSurfaceType(SurfaceType surfaceType)
Sets the surfaceType of the window.
Specifies whether the window is meant for raster rendering with QBackingStore, or OpenGL rendering with QOpenGLContext.
The 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() and create() to release the old native surface and create a new one.
参见 surfaceType(), QBackingStore, QOpenGLContext, create(), and destroy().
void QWindow::setTransientParent(QWindow *parent)
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 (such as Qt::Dialog
).
参见 transientParent() and parent().
void QWindow::setWindowState(Qt::WindowState state)
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.
The enum value Qt::WindowActive is not an accepted parameter.
参见 windowState(), showNormal(), showFullScreen(), showMinimized(), and showMaximized().
[slot]
void QWindow::show()
Shows the window.
This is equivalent to calling showFullScreen(), showMaximized(), or showNormal(), depending on the platform's default behavior for the window type and flags.
参见 showFullScreen(), showMaximized(), showNormal(), hide(), QStyleHints::showIsFullScreen(), and flags().
[virtual protected]
void QWindow::showEvent(QShowEvent *ev)
Override this to handle show events (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()
Shows the window as fullscreen.
Equivalent to calling setWindowState(Qt::WindowFullScreen) and then setVisible(true).
参见 setWindowState() and setVisible().
[slot]
void QWindow::showMaximized()
Shows the window as maximized.
Equivalent to calling setWindowState(Qt::WindowMaximized) and then setVisible(true).
参见 setWindowState() and setVisible().
[slot]
void QWindow::showMinimized()
Shows the window as minimized.
Equivalent to calling setWindowState(Qt::WindowMinimized) and then setVisible(true).
参见 setWindowState() and setVisible().
[slot]
void QWindow::showNormal()
Shows the window as normal, i.e. neither maximized, minimized, nor fullscreen.
Equivalent to calling setWindowState(Qt::WindowNoState) and then setVisible(true).
参见 setWindowState() and setVisible().
[virtual]
QSize QWindow::size() const
Reimplemented from QSurface::size().
Returns the size of the window excluding any window frame
参见 resize().
QSize QWindow::sizeIncrement() const
Returns the size increment of the window.
参见 setSizeIncrement().
[virtual]
SurfaceType QWindow::surfaceType() const
Reimplemented from QSurface::surfaceType().
Returns the surface type of the window.
参见 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).
QWindow *QWindow::transientParent() const
Returns the transient parent of the window.
参见 setTransientParent() and parent().
Qt::WindowType QWindow::type() const
Returns the type of the window.
This returns the part of the window flags that represents whether the window is a dialog, tooltip, popup, regular window, etc.
void QWindow::unsetCursor()
Restores the default arrow cursor for this window.
[virtual protected]
void QWindow::wheelEvent(QWheelEvent *ev)
Override this to handle mouse wheel or other wheel events (ev).
WId QWindow::winId() const
Returns the window's platform id.
For platforms where this id might be useful, the value returned will uniquely represent the window inside the corresponding screen.
参见 screen().
Qt::WindowState QWindow::windowState() const
the screen-occupation state of the window
参见 setWindowState().
[signal]
void QWindow::windowStateChanged(Qt::WindowState windowState)
This signal is emitted when the windowState changes, either by being set explicitly with setWindowState(), or automatically when the user clicks one of the titlebar buttons or by other means.