QQuickWindow 类

The QQuickWindow class provides the window for displaying a graphical QML scene. 更多...

头: #include <QQuickWindow>
qmake: QT += quick
Since: Qt 5.0
实例化: Window
继承: QWindow
继承者: QQuickView

公共类型

enum CreateTextureOption { TextureHasAlphaChannel, TextureHasMipmaps, TextureOwnsGLTexture, TextureCanUseAtlas, TextureIsOpaque }
flags CreateTextureOptions
enum RenderStage { BeforeSynchronizingStage, AfterSynchronizingStage, BeforeRenderingStage, AfterRenderingStage, AfterSwapStage, NoStage }
enum SceneGraphError { ContextNotAvailable }
enum TextRenderType { QtTextRendering, NativeTextRendering }

特性

公共函数

QQuickWindow (QWindow * parent = nullptr)
virtual ~QQuickWindow () override
QQuickItem * activeFocusItem () const
bool clearBeforeRendering () const
QColor color () const
QQuickItem * contentItem () const
QSGImageNode * createImageNode () const
QSGNinePatchNode * createNinePatchNode () const
QSGRectangleNode * createRectangleNode () const
QSGTexture * createTextureFromId (uint id , const QSize & size , QQuickWindow::CreateTextureOptions options = CreateTextureOption()) const
QSGTexture * createTextureFromImage (const QImage & image , QQuickWindow::CreateTextureOptions options ) const
QSGTexture * createTextureFromImage (const QImage & image ) const
qreal effectiveDevicePixelRatio () const
QImage grabWindow ()
QQmlIncubationController * incubationController () const
bool isPersistentOpenGLContext () const
bool isPersistentSceneGraph () const
bool isSceneGraphInitialized () const
QQuickItem * mouseGrabberItem () const
QOpenGLContext * openglContext () const
QOpenGLFramebufferObject * renderTarget () const
uint renderTargetId () const
QSize renderTargetSize () const
QSGRendererInterface * rendererInterface () const
void resetOpenGLState ()
void scheduleRenderJob (QRunnable * job , QQuickWindow::RenderStage stage )
void setClearBeforeRendering (bool enabled )
void setColor (const QColor & color )
void setPersistentOpenGLContext (bool persistent )
void setPersistentSceneGraph (bool persistent )
void setRenderTarget (QOpenGLFramebufferObject * fbo )
void setRenderTarget (uint fboId , const QSize & size )

重实现公共函数

virtual QAccessibleInterface * accessibleRoot () const override

公共槽

void releaseResources ()
void update ()

信号

void activeFocusItemChanged ()
void afterAnimating ()
void afterRendering ()
void afterSynchronizing ()
void beforeRendering ()
void beforeSynchronizing ()
void closing (QQuickCloseEvent * close )
void colorChanged ( const QColor & )
void frameSwapped ()
void openglContextCreated (QOpenGLContext * context )
void sceneGraphAboutToStop ()
void sceneGraphError (QQuickWindow::SceneGraphError error , const QString & message )
void sceneGraphInitialized ()
void sceneGraphInvalidated ()

静态公共成员

bool hasDefaultAlphaBuffer ()
QString sceneGraphBackend ()
void setDefaultAlphaBuffer (bool useAlpha )
void setSceneGraphBackend (QSGRendererInterface::GraphicsApi api )
void setSceneGraphBackend (const QString & backend )
void setTextRenderType (QQuickWindow::TextRenderType renderType )
const QMetaObject staticMetaObject
QQuickWindow::TextRenderType textRenderType ()

重实现保护函数

virtual bool event (QEvent * e ) override
virtual void exposeEvent ( QExposeEvent * ) override
virtual void focusInEvent (QFocusEvent * ev ) override
virtual void focusOutEvent (QFocusEvent * ev ) override
virtual void hideEvent ( QHideEvent * ) override
virtual void keyPressEvent (QKeyEvent * e ) override
virtual void keyReleaseEvent (QKeyEvent * e ) override
virtual void mouseDoubleClickEvent (QMouseEvent * event ) override
virtual void mouseMoveEvent (QMouseEvent * event ) override
virtual void mousePressEvent (QMouseEvent * event ) override
virtual void mouseReleaseEvent (QMouseEvent * event ) override
virtual void resizeEvent (QResizeEvent * ev ) override
virtual void showEvent ( QShowEvent * ) override
virtual void wheelEvent (QWheelEvent * event ) override

详细描述

The QQuickWindow class provides the window for displaying a graphical QML scene.

QQuickWindow provides the graphical scene management needed to interact with and display a scene of QQuickItems.

A QQuickWindow always has a single invisible root item. To add items to this window, reparent the items to the root item or to an existing item in the scene.

为轻松从 QML 文件显示场景,见 QQuickView .

渲染

QQuickWindow uses a scene graph to represent what needs to be rendered. This scene graph is disconnected from the QML scene and potentially lives in another thread, depending on the platform implementation. Since the rendering scene graph lives independently from the QML scene, it can also be completely released without affecting the state of the QML scene.

The sceneGraphInitialized () signal is emitted on the rendering thread before the QML scene is rendered to the screen for the first time. If the rendering scene graph has been released, the signal will be emitted again before the next frame is rendered.

集成 OpenGL

When using the default OpenGL adaptation, it is possible to integrate OpenGL calls directly into the QQuickWindow using the same OpenGL context as the Qt Quick Scene Graph. This is done by connecting to the QQuickWindow::beforeRendering () 或 QQuickWindow::afterRendering () 信号。

注意: 当使用 QQuickWindow::beforeRendering (), make sure to disable clearing before rendering with QQuickWindow::setClearBeforeRendering ().

曝光和可见性

QQuickWindow instance is deliberately hidden with hide () 或 setVisible (false), it will stop rendering and its scene graph and graphics context might be released. The sceneGraphInvalidated () signal will be emitted when this happens.

警告: It is crucial that graphics operations and interaction with the scene graph happens exclusively on the rendering thread, primarily during the updatePaintNode() phase.

警告: As signals related to rendering might be emitted from the rendering thread, connections should be made using Qt::DirectConnection .

资源管理

QML will try to cache images and scene graph nodes to improve performance, but in some low-memory scenarios it might be required to aggressively release these resources. The releaseResources () can be used to force the clean up of certain resources. Calling releaseResources () may result in the entire scene graph and in the case of the OpenGL adaptation the associated context will be deleted. The sceneGraphInvalidated () signal will be emitted when this happens.

注意: 所有带有 QSG 前缀的类只应用于场景图形渲染线程。见 场景图形和渲染 了解更多信息。

上下文和表面格式

While it is possible to specify a QSurfaceFormat for every QQuickWindow by calling the member function setFormat (), windows may also be created from QML by using the Window and ApplicationWindow elements. In this case there is no C++ code involved in the creation of the window instance, yet applications may still wish to set certain surface format values, for example to request a given OpenGL version or profile. Such applications can call the static function QSurfaceFormat::setDefaultFormat () at startup. The specified format will be used for all Quick windows created afterwards.

另请参阅 场景图形 - QML 下的 OpenGL .

成员类型文档编制

enum QQuickWindow:: CreateTextureOption
flags QQuickWindow:: CreateTextureOptions

The CreateTextureOption enums are used to customize a texture is wrapped.

常量 描述
QQuickWindow::TextureHasAlphaChannel 0x0001 The texture has an alpha channel and should be drawn using blending.
QQuickWindow::TextureHasMipmaps 0x0002 The texture has mipmaps and can be drawn with mipmapping enabled.
QQuickWindow::TextureOwnsGLTexture 0x0004 The texture object owns the texture id and will delete the OpenGL texture when the texture object is deleted.
QQuickWindow::TextureCanUseAtlas 0x0008 The image can be uploaded into a texture atlas.
QQuickWindow::TextureIsOpaque 0x0010 The texture will return false for QSGTexture::hasAlphaChannel () and will not be blended. This flag was added in Qt 5.6.

CreateTextureOptions 类型是 typedef 对于 QFlags <CreateTextureOption>. It stores an OR combination of CreateTextureOption values.

enum QQuickWindow:: RenderStage

常量 描述
QQuickWindow::BeforeSynchronizingStage 0 在同步前。
QQuickWindow::AfterSynchronizingStage 1 在同步后。
QQuickWindow::BeforeRenderingStage 2 在渲染前。
QQuickWindow::AfterRenderingStage 3 在渲染后。
QQuickWindow::AfterSwapStage 4 在帧交换后。
QQuickWindow::NoStage 5 尽快。该值在 Qt 5.6 添加。

该枚举在 Qt 5.4 引入或被修改。

另请参阅 场景图形和渲染 .

enum QQuickWindow:: SceneGraphError

此枚举描述的错误在 sceneGraphError () 信号。

常量 描述
QQuickWindow::ContextNotAvailable 1 graphics context creation failed. This typically means that no suitable OpenGL implementation was found, for example because no graphics drivers are installed and so no OpenGL 2 support is present. On mobile and embedded boards that use OpenGL ES such an error is likely to indicate issues in the windowing system integration and possibly an incorrect configuration of Qt.

该枚举在 Qt 5.3 引入或被修改。

enum QQuickWindow:: TextRenderType

此枚举描述 Qt Quick 中像文本元素的默认渲染类型 ( Text , TextInput ,等)。

Select NativeTextRendering if you prefer text to look native on the target platform and do not require advanced features such as transformation of the text. Using such features in combination with the NativeTextRendering render type will lend poor and sometimes pixelated results.

常量 描述
QQuickWindow::QtTextRendering 0 使用 Qt 自己的光栅化算法。
QQuickWindow::NativeTextRendering 1 对文本使用 OS (操作系统) 的本机光栅化器。

该枚举在 Qt 5.10 引入或被修改。

特性文档编制

activeFocusItem : QQuickItem * const

此特性保持的项目前拥有活动聚焦或 null 若没有项具有活动聚焦。

访问函数:

QQuickItem * activeFocusItem () const

通知程序信号:

void activeFocusItemChanged ()

color : QColor

此特性保持用于清零 OpenGL 上下文的颜色。

设置清零颜色不起作用,当清零被禁用时。默认情况下,清零颜色为白色。

访问函数:

QColor color () const
void setColor (const QColor & color )

通知程序信号:

void colorChanged ( const QColor & )

另请参阅 setClearBeforeRendering () 和 setDefaultAlphaBuffer ().

contentItem : QQuickItem * const

此特性保持场景的不可见根项。

A QQuickWindow always has a single invisible root item containing all of its content. To add items to this window, reparent the items to the contentItem or to an existing item in the scene.

访问函数:

QQuickItem * contentItem () const

成员函数文档编制

QQuickWindow:: QQuickWindow ( QWindow * parent = nullptr)

构造窗口为显示 QML 场景采用父级窗口 parent .

[override virtual] QQuickWindow:: ~QQuickWindow ()

销毁窗口。

[override virtual] QAccessibleInterface *QQuickWindow:: accessibleRoot () const

返回此窗口的可访问接口,或 0 若无法创建这种接口。

[signal] void QQuickWindow:: afterAnimating ()

This signal is emitted on the gui thread before requesting the render thread to perform the synchronization of the scene graph.

Unlike the other similar signals, this one is emitted on the gui thread instead of the render thread. It can be used to synchronize external animation systems with the QML content.

该函数在 Qt 5.3 引入。

[signal] void QQuickWindow:: afterRendering ()

此信号在场景已完成渲染后发射,在 swapbuffers 被调用前。

此信号可以用于在 QML 内容上使用原生 OpenGL 进行描绘,或对当前帧缓冲做屏幕抓取。

用于渲染场景图形的 OpenGL 上下文,会被绑定在此点。

警告: This signal is emitted from the scene graph rendering thread. If your slot function needs to finish before execution continues, you must make sure that the connection is direct (see Qt::ConnectionType ).

警告: Make very sure that a signal handler for afterRendering() leaves the OpenGL context in the same state as it was when the signal handler was entered. Failing to do so can result in the scene not rendering properly.

另请参阅 resetOpenGLState ().

[signal] void QQuickWindow:: afterSynchronizing ()

此信号被发射,在场景图形与 QML 状态同步后。

This signal can be used to do preparation required after calls to QQuickItem::updatePaintNode (), while the GUI thread is still locked.

用于渲染场景图形的图形上下文,会被绑定在此点。

警告: This signal is emitted from the scene graph rendering thread. If your slot function needs to finish before execution continues, you must make sure that the connection is direct (see Qt::ConnectionType ).

警告: When using the OpenGL adaptation, make sure that a signal handler for afterSynchronizing leaves the OpenGL context in the same state as it was when the signal handler was entered. Failing to do so can result in the scene not rendering properly.

该函数在 Qt 5.3 引入。

另请参阅 resetOpenGLState ().

[signal] void QQuickWindow:: beforeRendering ()

此信号被发射,在开始渲染场景之前。

Combined with the modes for clearing the background, this option can be used to paint using raw OpenGL under QML content.

用于渲染场景图形的 OpenGL 上下文,会被绑定在此点。

警告: This signal is emitted from the scene graph rendering thread. If your slot function needs to finish before execution continues, you must make sure that the connection is direct (see Qt::ConnectionType ).

警告: Make very sure that a signal handler for beforeRendering leaves the OpenGL context in the same state as it was when the signal handler was entered. Failing to do so can result in the scene not rendering properly.

另请参阅 resetOpenGLState ().

[signal] void QQuickWindow:: beforeSynchronizing ()

This signal is emitted before the scene graph is synchronized with the QML state.

This signal can be used to do any preparation required before calls to QQuickItem::updatePaintNode ().

用于渲染场景图形的 OpenGL 上下文,会被绑定在此点。

警告: This signal is emitted from the scene graph rendering thread. If your slot function needs to finish before execution continues, you must make sure that the connection is direct (see Qt::ConnectionType ).

警告: Make very sure that a signal handler for beforeSynchronizing leaves the GL context in the same state as it was when the signal handler was entered. Failing to do so can result in the scene not rendering properly.

另请参阅 resetOpenGLState ().

bool QQuickWindow:: clearBeforeRendering () const

返回是否做做颜色缓冲清零,在渲染前。

另请参阅 setClearBeforeRendering ().

[signal] void QQuickWindow:: closing ( QQuickCloseEvent * close )

此信号被发,当窗口收到事件 close 从窗口系统。

该函数在 Qt 5.1 引入。

QSGImageNode *QQuickWindow:: createImageNode () const

创建简单图像节点。当场景图形未初始化时,返回值为 null。

这是直接构造 QSGSimpleTextureNode 的跨后端替代。

该函数在 Qt 5.8 引入。

另请参阅 QSGImageNode .

QSGNinePatchNode *QQuickWindow:: createNinePatchNode () const

创建 9 个补丁节点。当场景图形未初始化时,返回值为 null。

该函数在 Qt 5.8 引入。

QSGRectangleNode *QQuickWindow:: createRectangleNode () const

创建简单矩形节点。当场景图形未初始化时,返回值为 null。

这是直接构造 QSGSimpleRectNode 的跨后端替代。

该函数在 Qt 5.8 引入。

另请参阅 QSGRectangleNode .

QSGTexture *QQuickWindow:: createTextureFromId ( uint id , const QSize & size , QQuickWindow::CreateTextureOptions options = CreateTextureOption()) const

创建新的 QSGTexture object from an existing OpenGL texture id and size .

The caller of the function is responsible for deleting the returned texture.

The returned texture will be using GL_TEXTURE_2D as texture target and assumes that internal format is GL_RGBA 。重实现 QSGTexture 能创建具有不同参数的纹理。

使用 options to customize the texture attributes. The TextureUsesAtlas option is ignored.

警告: This function will return null if the scenegraph has not yet been initialized or OpenGL is not in use.

注意: 此函数才起作用,当使用默认 OpenGL 场景图形适配时。

另请参阅 sceneGraphInitialized () 和 QSGTexture .

QSGTexture *QQuickWindow:: createTextureFromImage (const QImage & image , QQuickWindow::CreateTextureOptions options ) const

创建新的 QSGTexture 从供给 image 。若图像拥有 Alpha 通道,相应纹理将拥有 Alpha 通道。

函数的调用者负责删除返回纹理。例如,会删除使用 OpenGL 适配的实际 OpenGL 纹理,当删除纹理对象时。

options 包含 TextureCanUseAtlas ,引擎可以将图像放入纹理图集。图集中的纹理需要依赖 QSGTexture::normalizedTextureSubRect () 为它们的几何体且不支持 QSGTexture::Repeat 。其它值来自 CreateTextureOption 被忽略。

options 包含 TextureIsOpaque , the engine will create an RGB texture which returns false for QSGTexture::hasAlphaChannel (). Opaque textures will in most cases be faster to render. When this flag is not set, the texture will have an alpha channel based on the image's format.

options 包含 TextureHasMipmaps , the engine will create a texture which can use mipmap filtering. Mipmapped textures can not be in an atlas.

当使用 OpenGL 适配时,返回纹理将使用 GL_TEXTURE_2D 作纹理目标和 GL_RGBA 作内部格式。重实现 QSGTexture 能创建具有不同参数的纹理。

警告: 此函数将返回 0 若场景图形尚未初始化。

警告: The returned texture is not memory managed by the scene graph and must be explicitly deleted by the caller on the rendering thread. This is achieved by deleting the texture from a QSGNode destructor or by using deleteLater () in the case where the texture already has affinity to the rendering thread.

可以从任何线程中调用此函数。

另请参阅 sceneGraphInitialized () 和 QSGTexture .

QSGTexture *QQuickWindow:: createTextureFromImage (const QImage & image ) const

这是重载函数。

qreal QQuickWindow:: effectiveDevicePixelRatio () const

返回用于此窗口的设备像素比率。

这不同于 QWindow::devicePixelRatio () in that it supports redirected rendering via QQuickRenderControl 。当使用 QQuickRenderControl QQuickWindow is often not created, meaning it is never shown and there is no underlying native window created in the windowing system. As a result, querying properties like the device pixel ratio cannot give correct results. Use this function instead.

另请参阅 QWindow::devicePixelRatio ().

[override virtual protected] bool QQuickWindow:: event ( QEvent * e )

重实现自 QWindow::event ().

[override virtual protected] void QQuickWindow:: exposeEvent ( QExposeEvent * )

重实现自 QWindow::exposeEvent ().

[override virtual protected] void QQuickWindow:: focusInEvent ( QFocusEvent * ev )

重实现自 QWindow::focusInEvent ().

[override virtual protected] void QQuickWindow:: focusOutEvent ( QFocusEvent * ev )

重实现自 QWindow::focusOutEvent ().

[signal] void QQuickWindow:: frameSwapped ()

This signal is emitted when a frame has been queued for presenting. With vertical synchronization enabled the signal is emitted at most once per vsync interval in a continuously animating scene.

此信号将从场景图形渲染线程中发射。

QImage QQuickWindow:: grabWindow ()

Grabs the contents of the window and returns it as an image.

It is possible to call the grabWindow() function when the window is not visible. This requires that the window is created and has a valid size and that no other QQuickWindow instances are rendering in the same process.

警告: Calling this function will cause performance problems.

警告: 只可以从 GUI 线程是调用此函数。

[static] bool QQuickWindow:: hasDefaultAlphaBuffer ()

Returns whether to use alpha transparency on newly created windows.

该函数在 Qt 5.1 引入。

另请参阅 setDefaultAlphaBuffer ().

[override virtual protected] void QQuickWindow:: hideEvent ( QHideEvent * )

重实现自 QWindow::hideEvent ().

QQmlIncubationController *QQuickWindow:: incubationController () const

Returns an incubation controller that splices incubation between frames for this window. QQuickView automatically installs this controller for you, otherwise you will need to install it yourself using QQmlEngine::setIncubationController ().

The controller is owned by the window and will be destroyed when the window is deleted.

bool QQuickWindow:: isPersistentOpenGLContext () const

Returns whether the OpenGL context can be released during the lifetime of the QQuickWindow .

注意: This is a hint. When and how this happens is implementation specific. It also only has an effect when using the default OpenGL scene graph adaptation

bool QQuickWindow:: isPersistentSceneGraph () const

Returns whether the scene graph nodes and resources can be released during the lifetime of this QQuickWindow .

注意: This is a hint. When and how this happens is implementation specific.

bool QQuickWindow:: isSceneGraphInitialized () const

Returns true if the scene graph has been initialized; otherwise returns false.

[override virtual protected] void QQuickWindow:: keyPressEvent ( QKeyEvent * e )

重实现自 QWindow::keyPressEvent ().

[override virtual protected] void QQuickWindow:: keyReleaseEvent ( QKeyEvent * e )

重实现自 QWindow::keyReleaseEvent ().

[override virtual protected] void QQuickWindow:: mouseDoubleClickEvent ( QMouseEvent * event )

重实现自 QWindow::mouseDoubleClickEvent ().

QQuickItem *QQuickWindow:: mouseGrabberItem () const

返回目前有抓取鼠标的项。

[override virtual protected] void QQuickWindow:: mouseMoveEvent ( QMouseEvent * event )

重实现自 QWindow::mouseMoveEvent ().

[override virtual protected] void QQuickWindow:: mousePressEvent ( QMouseEvent * event )

重实现自 QWindow::mousePressEvent ().

[override virtual protected] void QQuickWindow:: mouseReleaseEvent ( QMouseEvent * event )

重实现自 QWindow::mouseReleaseEvent ().

QOpenGLContext *QQuickWindow:: openglContext () const

返回用于渲染的 OpenGL 上下文。

If the scene graph is not ready, or the scene graph is not using OpenGL, this function will return null.

注意: If using a scene graph adaptation other than OpenGL this function will return nullptr.

另请参阅 sceneGraphInitialized () 和 sceneGraphInvalidated ().

[signal] void QQuickWindow:: openglContextCreated ( QOpenGLContext * context )

This signal is emitted on the gui thread when the OpenGL context 对于此窗口有创建,在它变为当前前。

某些实现会共享同一 OpenGL 上下文介于多个 QQuickWindow instances. The openglContextCreated() signal will in this case only be emitted for the first window, when the OpenGL context is actually created.

QQuickWindow::openglContext () will still return 0 for this window until after the QQuickWindow::sceneGraphInitialize() has been emitted.

注意: This signal will only be emmited when using the default OpenGL scene graph adaptation.

该函数在 Qt 5.3 引入。

[slot] void QQuickWindow:: releaseResources ()

此函数会试着释放目前由 QML 场景保持的冗余资源。

Calling this function might result in the scene graph and the OpenGL context used for rendering being released to release graphics memory. If this happens, the sceneGraphInvalidated () signal will be called, allowing users to clean up their own graphics resources. The setPersistentOpenGLContext () 和 setPersistentSceneGraph () functions can be used to prevent this from happening, if handling the cleanup is not feasible in the application, at the cost of higher memory usage.

另请参阅 sceneGraphInvalidated (), setPersistentOpenGLContext (),和 setPersistentSceneGraph ().

QOpenGLFramebufferObject *QQuickWindow:: renderTarget () const

返回用于此窗口的渲染目标。

The default is to render to the surface of the window, in which case the render target is 0.

注意: This function will return nullptr when not using the OpenGL scene graph adaptation.

另请参阅 setRenderTarget ().

uint QQuickWindow:: renderTargetId () const

返回渲染目标的 FBO (帧缓冲对象) ID 当有设置时;否则返回 0。

QSize QQuickWindow:: renderTargetSize () const

返回目前设置的渲染目标的大小;否则返回空大小。

QSGRendererInterface *QQuickWindow:: rendererInterface () const

返回当前渲染器接口。值始终有效且从不为 null。

注意: 可以在任何时候调用此函数,后于构造 QQuickWindow ,即使 isSceneGraphInitialized () 仍为 false。不管怎样,某些渲染器接口函数,尤其 QSGRendererInterface::getResource () will not be functional until the scenegraph is up and running. Backend queries, like QSGRendererInterface::graphicsApi () 或 QSGRendererInterface::shaderType (), will always be functional on the other hand.

注意: The ownership of the returned pointer stays with Qt. The returned instance may or may not be shared between different QQuickWindow instances, depending on the scenegraph backend in use. Therefore applications are expected to query the interface object for each QQuickWindow instead of reusing the already queried pointer.

该函数在 Qt 5.8 引入。

另请参阅 QSGRenderNode and QSGRendererInterface .

void QQuickWindow:: resetOpenGLState ()

调用此函数以重置 OpenGL 上下文的默认状态。

The scene graph uses the OpenGL context and will both rely on and clobber its state. When mixing raw OpenGL commands with scene graph rendering, this function provides a convenient way of resetting the OpenGL context state back to its default values.

此函数不涉及固定函数管道中的状态。

This function does not clear the color, depth and stencil buffers. Use QQuickWindow::setClearBeforeRendering to control clearing of the color buffer. The depth and stencil buffer might be clobbered by the scene graph renderer. Clear these manually on demand.

注意: 此函数才起作用,当使用默认 OpenGL 场景图形适配时。

该函数在 Qt 5.2 引入。

另请参阅 QQuickWindow::beforeRendering ().

[override virtual protected] void QQuickWindow:: resizeEvent ( QResizeEvent * ev )

重实现自 QWindow::resizeEvent ().

[signal] void QQuickWindow:: sceneGraphAboutToStop ()

This signal is emitted on the render thread when the scene graph is about to stop rendering. This happens usually because the window has been hidden.

Applications may use this signal to release resources, but should be prepared to reinstantiated them again fast. The scene graph and the graphics context are not released at this time.

警告: This signal is emitted from the scene graph rendering thread. If your slot function needs to finish before execution continues, you must make sure that the connection is direct (see Qt::ConnectionType ).

警告: Make very sure that a signal handler for sceneGraphAboutToStop() leaves the graphics context in the same state as it was when the signal handler was entered. Failing to do so can result in the scene not rendering properly.

该函数在 Qt 5.3 引入。

另请参阅 sceneGraphInvalidated () 和 resetOpenGLState ().

[static] QString QQuickWindow:: sceneGraphBackend ()

返回请求的 Qt Quick 场景图形后端。

注意: 此函数的返回值可能仍过时通过后续调用 setSceneGraphBackend () 直到第一 QQuickWindow 在应用程序中已构造。

该函数在 Qt 5.9 引入。

另请参阅 setSceneGraphBackend ().

[signal] void QQuickWindow:: sceneGraphError ( QQuickWindow::SceneGraphError error , const QString & message )

此信号发射当 error 出现在场景图形初始化期间。

Applications should connect to this signal if they wish to handle errors, like graphics context creation failures, in a custom way. When no slot is connected to the signal, the behavior will be different: Quick will print the message , or show a message box, and terminate the application.

This signal will be emitted from the gui thread.

该函数在 Qt 5.3 引入。

[signal] void QQuickWindow:: sceneGraphInitialized ()

此信号被发射,当场景图形已初始化。

此信号将从场景图形渲染线程中发射。

[signal] void QQuickWindow:: sceneGraphInvalidated ()

此信号被发射,当场景图形已无效。

This signal implies that the graphics rendering context used has been invalidated and all user resources tied to that context should be released.

In the case of the default OpenGL adaptation the context of this window will be bound when this function is called. The only exception is if the native OpenGL has been destroyed outside Qt's control, for instance through EGL_CONTEXT_LOST.

此信号将从场景图形渲染线程中发射。

void QQuickWindow:: scheduleRenderJob ( QRunnable * job , QQuickWindow::RenderStage stage )

调度 job to run when the rendering of this window reaches the given stage .

这很方便对于等价信号在 QQuickWindow for "one shot" tasks.

窗口拥有所有权对于 job 且会删除它当 job 完成时。

If rendering is shut down before job has a chance to run, the job will be run and then deleted as part of the scene graph cleanup. If the window is never shown and no rendering happens before the QQuickWindow is destroyed, all pending jobs will be destroyed without their run() method being called.

若渲染发生在不同线程,那么 job 将发生在渲染线程。

stage is NoStage , job will be run at the earliest opportunity whenever the render thread is not busy rendering a frame. If there is no OpenGL context available or the window is not exposed at the time the job is either posted or handled, it is deleted without executing the run() method. If a non-threaded renderer is in use, the run() method of the job is executed synchronously. The OpenGL context is changed to the renderer context before executing a NoStage job.

注意: This function does not trigger rendering; the jobs targeting any other stage than NoStage will be stored run until rendering is triggered elsewhere. To force the job to run earlier, call QQuickWindow::update ();

该函数在 Qt 5.4 引入。

另请参阅 beforeRendering (), afterRendering (), beforeSynchronizing (), afterSynchronizing (), frameSwapped (),和 sceneGraphInvalidated ().

void QQuickWindow:: setClearBeforeRendering ( bool enabled )

设置 QML 场景图形的渲染是否应清零颜色缓冲,先于开始渲染 enabled .

通过禁用颜色缓冲的清零,在场景图形中渲染 OpengGL 内容是可能的。

颜色缓冲被清零,默认情况下。

另请参阅 clearBeforeRendering () 和 beforeRendering ().

[static] void QQuickWindow:: setDefaultAlphaBuffer ( bool useAlpha )

useAlpha 指定是否在新近创建的窗口中使用 Alpha 透明度。

在任何期望创建半透明窗口的应用程序中,有必要将此设为 true 先于创建第一 QQuickWindow 。默认值为 false。

该函数在 Qt 5.1 引入。

另请参阅 hasDefaultAlphaBuffer ().

void QQuickWindow:: setPersistentOpenGLContext ( bool persistent )

Sets whether the OpenGL context should be preserved, and cannot be released until the last window is deleted, to persistent 。默认值为 true。

The OpenGL context can be released to free up graphics resources when the window is obscured, hidden or not rendering. When this happens is implementation specific.

The QOpenGLContext::aboutToBeDestroyed () signal is emitted from the QQuickWindow::openglContext () when the OpenGL context is about to be released. The QQuickWindow::sceneGraphInitialized () signal is emitted when a new OpenGL context is created for this window. Make a Qt::DirectConnection to these signals to be notified.

OpenGL 上下文仍然会被释放,当最后一个 QQuickWindow 被删除。

注意: This only has an effect when using the default OpenGL scene graph adaptation.

另请参阅 isPersistentOpenGLContext (), setPersistentSceneGraph (), QOpenGLContext::aboutToBeDestroyed (),和 sceneGraphInitialized ().

void QQuickWindow:: setPersistentSceneGraph ( bool persistent )

Sets whether the scene graph nodes and resources can be released to persistent 。默认值为 true。

The scene graph nodes and resources can be released to free up graphics resources when the window is obscured, hidden or not rendering. When this happens is implementation specific.

The QQuickWindow::sceneGraphInvalidated () signal is emitted when cleanup occurs. The QQuickWindow::sceneGraphInitialized () signal is emitted when a new scene graph is recreated for this window. Make a Qt::DirectConnection to these signals to be notified.

The scene graph nodes and resources are still released when the last QQuickWindow 被删除。

另请参阅 isPersistentSceneGraph (), setPersistentOpenGLContext (), sceneGraphInvalidated (),和 sceneGraphInitialized ().

void QQuickWindow:: setRenderTarget ( QOpenGLFramebufferObject * fbo )

将用于此窗口的渲染目标设为 fbo .

指定的 FBO (帧缓冲对象) 必须在窗口的上下文 (或与之共享的某个上下文) 中被创建。

注意: 此函数才起作用,当使用默认 OpenGL 场景图形适配时。

警告: 只可以从做渲染的线程中调用此函数。

另请参阅 renderTarget ().

void QQuickWindow:: setRenderTarget ( uint fboId , const QSize & size )

这是重载函数。

将用于此窗口的渲染目标设为 FBO (帧缓冲对象) 采用 fboId and size .

指定的 FBO (帧缓冲对象) 必须在窗口的上下文 (或与之共享的某个上下文) 中被创建。

注意: fboId can also be set to 0. In this case rendering will target the default framebuffer of whichever surface is current when the scenegraph renders. size must still be valid, specifying the dimensions of the surface.

注意: 此函数才起作用,当使用默认 OpenGL 场景图形适配时。

警告: 只可以从做渲染的线程中调用此函数。

[static] void QQuickWindow:: setSceneGraphBackend ( QSGRendererInterface::GraphicsApi api )

请求 Qt Quick 场景图形后端对于指定图形 api 。后端要么可以是内置的,要么以动态加载插件的形式安装。

注意: 函数调用的发生必须先于构造第一 QQuickWindow 在应用程序中。之后无法改变。

若选中后端无效 (或出现错误),使用默认后端 (OpenGL 或软件,从属 Qt 配置)。

该函数在 Qt 5.8 引入。

另请参阅 sceneGraphBackend ().

[static] void QQuickWindow:: setSceneGraphBackend (const QString & backend )

请求指定 Qt Quick 场景图形 backend 。后端要么可以是内置的,要么以动态加载插件的形式安装。

这是重载函数。

注意: 函数调用的发生必须先于构造第一 QQuickWindow 在应用程序中。之后无法改变。

backend 无效 (或出现错误),使用默认后端 (OpenGL 或软件,从属 Qt 配置)。

注意: 调用此函数相当于设置 QT_QUICK_BACKEND or QMLSCENE_DEVICE 环境变量。不管怎样,在卵生其它进程的应用程序中使用此 API 更安全,因为不需要担心环境继承。

该函数在 Qt 5.8 引入。

[static] void QQuickWindow:: setTextRenderType ( QQuickWindow::TextRenderType renderType )

将 Qt Quick 中像文本元素的默认渲染类型设为 renderType .

注意: 设置渲染类型仅影响之后创建的元素;不会修改现有元素的渲染类型。

该函数在 Qt 5.10 引入。

另请参阅 textRenderType ().

[override virtual protected] void QQuickWindow:: showEvent ( QShowEvent * )

重实现自 QWindow::showEvent ().

[static] QQuickWindow::TextRenderType QQuickWindow:: textRenderType ()

返回 Qt Quick 中像文本元素的渲染类型。默认为 QQuickWindow::QtTextRendering .

该函数在 Qt 5.10 引入。

另请参阅 setTextRenderType ().

[slot] void QQuickWindow:: update ()

调度窗口以渲染另一帧。

调用 QQuickWindow::update() 不同于 QQuickItem::update () in that it always triggers a repaint, regardless of changes in the underlying scene graph or not.

[override virtual protected] void QQuickWindow:: wheelEvent ( QWheelEvent * event )

重实现自 QWindow::wheelEvent ().