QQuickWindow 類提供用於顯示圖形 QML 場景的窗口。 更多...
| 頭: | #include <QQuickWindow> |
| CMake: |
find_package(Qt6 REQUIRED COMPONENTS Quick)
target_link_libraries(mytarget PRIVATE Qt6::Quick) |
| qmake: | QT += quick |
| 實例化: | Window |
| 繼承: | QWindow |
| 繼承者: | QQuickView |
| struct | GraphicsStateInfo |
| 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) | |
| QQuickWindow (QQuickRenderControl * control ) | |
| virtual | ~QQuickWindow () override |
| QQuickItem * | activeFocusItem () const |
| void | beginExternalCommands () |
| QColor | color () const |
| QQuickItem * | contentItem () const |
| QSGImageNode * | createImageNode () const |
| QSGNinePatchNode * | createNinePatchNode () const |
| QSGRectangleNode * | createRectangleNode () const |
| QSGTexture * | createTextureFromImage (const QImage & image , QQuickWindow::CreateTextureOptions options ) const |
| QSGTexture * | createTextureFromImage (const QImage & image ) const |
| qreal | effectiveDevicePixelRatio () const |
| void | endExternalCommands () |
| QImage | grabWindow () |
| QQuickGraphicsConfiguration | graphicsConfiguration () const |
| QQuickGraphicsDevice | graphicsDevice () const |
| const QQuickWindow::GraphicsStateInfo & | graphicsStateInfo () |
| QQmlIncubationController * | incubationController () const |
| bool | isPersistentGraphics () const |
| bool | isPersistentSceneGraph () const |
| bool | isSceneGraphInitialized () const |
| QQuickRenderTarget | renderTarget () const |
| QSGRendererInterface * | rendererInterface () const |
| void | scheduleRenderJob (QRunnable * job , QQuickWindow::RenderStage stage ) |
| void | setColor (const QColor & color ) |
| void | setGraphicsConfiguration (const QQuickGraphicsConfiguration & config ) |
| void | setGraphicsDevice (const QQuickGraphicsDevice & device ) |
| void | setPersistentGraphics (bool persistent ) |
| void | setPersistentSceneGraph (bool persistent ) |
| void | setRenderTarget (const QQuickRenderTarget & target ) |
| virtual QAccessibleInterface * | accessibleRoot () const override |
| void | releaseResources () |
| void | update () |
| void | activeFocusItemChanged () |
| void | afterAnimating () |
| void | afterFrameEnd () |
| void | afterRenderPassRecording () |
| void | afterRendering () |
| void | afterSynchronizing () |
| void | beforeFrameBegin () |
| void | beforeRenderPassRecording () |
| void | beforeRendering () |
| void | beforeSynchronizing () |
| void | colorChanged (const QColor &) |
| void | frameSwapped () |
| void | sceneGraphAboutToStop () |
| void | sceneGraphError (QQuickWindow::SceneGraphError error , const QString & message ) |
| void | sceneGraphInitialized () |
| void | sceneGraphInvalidated () |
| QSGRendererInterface::GraphicsApi | graphicsApi () |
| bool | hasDefaultAlphaBuffer () |
| QString | sceneGraphBackend () |
| void | setDefaultAlphaBuffer (bool useAlpha ) |
| void | setGraphicsApi (QSGRendererInterface::GraphicsApi api ) |
| void | setSceneGraphBackend (const QString & backend ) |
| void | setTextRenderType (QQuickWindow::TextRenderType renderType ) |
| QQuickWindow::TextRenderType | textRenderType () |
| virtual void | closeEvent (QCloseEvent * e ) override |
| virtual bool | event (QEvent * event ) 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 | tabletEvent (QTabletEvent * event ) override |
| virtual void | wheelEvent (QWheelEvent * event ) override |
QQuickWindow 提供與 QQuickItems 場景交互和顯示,所需的圖形場景管理。
QQuickWindow 始終擁有單個不可見根項。要把項添加到此窗口,將項錶示成根項 (或場景中的現有項)。
為輕鬆從 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. A visible, on-screen QQuickWindow is driven internally by a
render loop
, of which there are multiple implementations provided in the scene graph. For details on the scene graph rendering process, see
Qt Quick 場景圖形
.
By default, a QQuickWindow renders using an accelerated 3D graphics API, such as OpenGL or Vulkan. See 場景圖形適配 for a detailed overview of scene graph backends and the supported graphics APIs.
警告: It is crucial that graphics operations and interaction with the scene graph happens exclusively on the rendering thread, primarily during the updatePaintNode() phase.
警告: As many of the signals related to rendering are emitted from the rendering thread, connections should be made using Qt::DirectConnection .
It is possible to integrate OpenGL, Vulkan, Metal, or Direct3D 11 calls directly into the QQuickWindow, as long as the QQuickWindow and the underlying scene graph is rendering using the same API. To access native graphics objects, such as device or context object handles, use QSGRendererInterface . An instance of QSGRendererInterface is queriable from QQuickWindow by calling rendererInterface (). The enablers for this integration are the beforeRendering (), beforeRenderPassRecording (), afterRenderPassRecording (), and related signals. These allow rendering underlays or overlays. Alternatively, QNativeInterface::QSGOpenGLTexture , QNativeInterface::QSGVulkanTexture , and other similar classes allow wrapping an existing native texture or image object in a QSGTexture that can then be used with the scene graph.
A limited, pure software based rendering path is available as well. With the
software
backend, a number of Qt Quick features are not available, QML items relying on these will not be rendered at all. At the same time, this allows QQuickWindow to be functional even on systems where there is no 3D graphics API available at all. See
Qt Quick Software Adaptation
瞭解更多細節。
A QQuickWindow is not necessarily backed by a native window on screen. The rendering can be redirected to target a custom render target, such as a given native texture. This is achieved in combination with the QQuickRenderControl class, and functions such as setRenderTarget (), setGraphicsDevice (),和 setGraphicsConfiguration ().
In this case, the QQuickWindow represents the scene, and provides the intrastructure for rendering a frame. It will not be backed by a render loop and a native window. Instead, in this case the application drives rendering, effectively substituting for the render loops. This allows generating image sequences, rendering into textures for use in external 3D engines, or rendering Qt Quick content within a VR environment.
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 () function can be used to force the clean up of certain resources, especially resource that are cached and can be recreated later when needed again.
Additionally, calling releaseResources () may result in releasing the entire scene graph and the associated graphics resources. The sceneGraphInvalidated () signal will be emitted when this happens. This behavior is controlled by the setPersistentGraphics () 和 setPersistentSceneGraph () 函數。
注意: 所有帶有 QSG 前綴的類隻應用於場景圖形渲染綫程。見 場景圖形和渲染 瞭解更多信息。
When a QQuickWindow instance is deliberately hidden with hide () or setVisible(false), it will stop rendering and its scene graph and graphics context might be released as well. This depends on the settings configured by setPersistentGraphics () 和 setPersistentSceneGraph (). The behavior in this respect is identical to explicitly calling the releaseResources () function. A window can become not exposed, in other words non-renderable, by other means as well. This depends on the platform and windowing system. For example, on Windows minimizing a window makes it stop rendering. On macOS fully obscuring a window by other windows on top triggers the same. On Linux/X11, the behavior is dependent on the window manager.
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.
When using Vulkan, a QQuickWindow is automatically associated with a
QVulkanInstance
that is created and managed internally by the scene graph. This way most applications do not need to worry about having a
VkInstance
available since it all happens automatically. In advanced cases an application may wish to create its own
QVulkanInstance
, in order to configure it in a specific way. That is possible as well. Calling
setVulkanInstance
() on the QQuickWindow right after construction, before making it visible, leads to using the application-supplied
QVulkanInstance
(and the underlying
VkInstance
). When redirecting via
QQuickRenderControl
, there is no
QVulkanInstance
provided automatically, but rather the application is expected to provide its own and associate it with the QQuickWindow.
When the scene graph is initialized, which typically happens when the window becomes exposed or, in case of redirected rendering, initialization is performed
via QQuickRenderControl
, the context or device objects necessary for rendering are created automatically. This includes OpenGL contexts, Direct3D devices and device contexts, Vulkan and Metal devices. These are also queriable by application code afterwards via
QSGRendererInterface
. When using the
basic
render loop, which performs all rendering on the GUI thread, the same context or device is used with all visible QQuickWindows. The
threaded
render loop uses a dedicated context or device object for each rendering thread, and so for each QQuickWindow. With some graphics APIs, there is a degree of customizability provided via
setGraphicsConfiguration
(). This makes it possible, for example, to specify the list of Vulkan extensions to enable on the
VkDevice
. Alternatively, it is also possible to provide a set of existing context or device objects for use by the QQuickWindow, instead of letting it construct its own. This is achieved through
setGraphicsDevice
().
另請參閱 QQuickView , QQuickRenderControl , QQuickRenderTarget , QQuickGraphicsDevice , QQuickGraphicsConfiguration ,和 QSGRendererInterface .
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
|
As of Qt 6.0, this flag is not used in practice and is ignored. Native graphics resource ownership is not transferable to the wrapping QSGTexture , because Qt Quick may not have the necessary details on how such an object and the associated memory should be freed. |
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.
| 常量 | 值 | 描述 |
|---|---|---|
QQuickWindow::BeforeSynchronizingStage
|
0
|
在同步前。 |
QQuickWindow::AfterSynchronizingStage
|
1
|
在同步後。 |
QQuickWindow::BeforeRenderingStage
|
2
|
在渲染前。 |
QQuickWindow::AfterRenderingStage
|
3
|
在渲染後。 |
QQuickWindow::AfterSwapStage
|
4
|
在幀交換後。 |
QQuickWindow::NoStage
|
5
|
盡快。該值在 Qt 5.6 添加。 |
另請參閱 場景圖形和渲染 .
此枚舉描述的錯誤在 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 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 (操作係統) 的本機光柵化器。 |
[read-only]
activeFocusItem
:
QQuickItem
* const
此特性保持的項目前擁有活動聚焦或
null
若沒有項具有活動聚焦。
訪問函數:
| QQuickItem * | activeFocusItem () const |
通知程序信號:
| void | activeFocusItemChanged () |
另請參閱 QQuickItem::forceActiveFocus () 和 Qt Quick 中的鍵盤聚焦 .
This property holds the color used to clear the color buffer at the beginning of each frame.
By default, the clear color is white.
訪問函數:
| QColor | color () const |
| void | setColor (const QColor & color ) |
通知程序信號:
| void | colorChanged (const QColor &) |
另請參閱 setDefaultAlphaBuffer ().
[read-only]
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 |
This property holds the window for which this window is a transient pop-up.
This is a hint to the window manager that this window is a dialog or pop-up on behalf of the transient parent, which may be any kind of QWindow .
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 set the
flags
property with a suitable
Qt::WindowType
(譬如
Qt::Dialog
).
另請參閱 parent ().
[explicit]
QQuickWindow::
QQuickWindow
(
QWindow
*
parent
= nullptr)
構造窗口為顯示 QML 場景采用父級窗口 parent .
[explicit]
QQuickWindow::
QQuickWindow
(
QQuickRenderControl
*
control
)
構造窗口為顯示 QML 場景,渲染的控製是通過 control 對象。請參考 QQuickRenderControl 文檔編製瞭解更多信息。
[override virtual]
QQuickWindow::
~QQuickWindow
()
銷毀窗口。
[override virtual]
QAccessibleInterface
*QQuickWindow::
accessibleRoot
() const
返迴此窗口的可訪問接口,或 0 若無法創建這種接口。
[signal]
void
QQuickWindow::
afterAnimating
()
此信號在 GUI 綫程中發射,在請求渲染綫程以履行場景圖形的同步前。
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. At the same time this means that this signal is not suitable for triggering graphics operations.
[signal, since 6.0]
void
QQuickWindow::
afterFrameEnd
()
This signal is emitted when the scene graph has submitted a frame. This is emitted after all other related signals, such as afterRendering (). It is the last signal that is emitted by the scene graph rendering thread when rendering a frame.
注意: 不像 frameSwapped (), this signal is guaranteed to be emitted also when the Qt Quick output is redirected via QQuickRenderControl .
警告: 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 ).
該函數在 Qt 6.0 引入。
另請參閱 beforeFrameBegin () 和 rendererInterface ().
[signal]
void
QQuickWindow::
afterRenderPassRecording
()
This signal is emitted after the scenegraph has recorded the commands for its main render pass, but the pass is not yet finalized on the command buffer.
This signal is emitted earlier than afterRendering (), and it guarantees that not just the frame but also the recording of the scenegraph's main render pass is still active. This allows inserting commands without having to generate an entire, separate render pass (which would typically clear the attached images). The native graphics objects can be queried via QSGRendererInterface .
注意: Resource updates (uploads, copies) typically cannot be enqueued from within a render pass. Therefore, more complex user rendering will need to connect to both beforeRendering () 和此信號。
警告: 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 ).
另請參閱 rendererInterface ().
[signal]
void
QQuickWindow::
afterRendering
()
The signal is emitted after scene graph has added its commands to the command buffer, which is not yet submitted to the graphics queue. If desired, the slot function connected to this signal can query native resources, like the command buffer, before via QSGRendererInterface . Note however that the render pass (or passes) are already recorded at this point and it is not possible to add more commands within the scenegraph's pass. Instead, use afterRenderPassRecording () for that. This signal has therefore limited use in Qt 6, unlike in Qt 5. Rather, it is the combination of beforeRendering () 和 beforeRenderPassRecording (),或 beforeRendering () 和 afterRenderPassRecording (), that is typically used to achieve under- or overlaying of the custom rendering.
When using OpenGL, the QOpenGLContext used for rendering by the scene graph will be bound at this point.
警告: 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 OpenGL, be aware that setting OpenGL 3.x or 4.x specific states and leaving these enabled or set to non-default values when returning from the connected slot can interfere with the scene graph's rendering.
另請參閱 rendererInterface (), 場景圖形 - QML 下的 OpenGL , 場景圖形 - 在 QML 下的 Metal , 場景圖形 - 在 QML 下的 Vulkan ,和 場景圖形 - 在 QML 下的 Direct3D 11 .
[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.
When using OpenGL, the QOpenGLContext used for rendering by the scene graph will be bound at this point.
警告: 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 OpenGL, be aware that setting OpenGL 3.x or 4.x specific states and leaving these enabled or set to non-default values when returning from the connected slot can interfere with the scene graph's rendering.
[signal, since 6.0]
void
QQuickWindow::
beforeFrameBegin
()
This signal is emitted before the scene graph starts preparing the frame. This precedes signals like beforeSynchronizing () 或 beforeRendering (). It is the earliest signal that is emitted by the scene graph rendering thread when starting to prepare a new frame.
This signal is relevant for lower level graphics frameworks that need to execute certain operations, such as resource cleanup, at a stage where Qt Quick has not initiated the recording of a new frame via the underlying rendering hardware interface APIs.
警告: 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 ).
該函數在 Qt 6.0 引入。
另請參閱 afterFrameEnd () 和 rendererInterface ().
[signal]
void
QQuickWindow::
beforeRenderPassRecording
()
This signal is emitted before the scenegraph starts recording commands for the main render pass. (Layers have their own passes and are fully recorded by the time this signal is emitted.) The render pass is already active on the command buffer when the signal is emitted.
This signal is emitted later than beforeRendering () and it guarantees that not just the frame, but also the recording of the scenegraph's main render pass is active. This allows inserting commands without having to generate an entire, separate render pass (which would typically clear the attached images). The native graphics objects can be queried via QSGRendererInterface .
注意: Resource updates (uploads, copies) typically cannot be enqueued from within a render pass. Therefore, more complex user rendering will need to connect to both beforeRendering () 和此信號。
警告: 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 ).
另請參閱 rendererInterface ().
[signal]
void
QQuickWindow::
beforeRendering
()
This signal is emitted after the preparations for the frame have been done, meaning there is a command buffer in recording mode, where applicable. If desired, the slot function connected to this signal can query native resources like the command before via QSGRendererInterface . Note however that the recording of the main render pass is not yet started at this point and it is not possible to add commands within that pass. Starting a pass means clearing the color, depth, and stencil buffers so it is not possible to achieve an underlay type of rendering by just connecting to this signal. Rather, connect to beforeRenderPassRecording (). However, connecting to this signal is still important if the recording of copy type of commands is desired since those cannot be enqueued within a render pass.
When using OpenGL, the QOpenGLContext used for rendering by the scene graph will be bound at this point.
警告: 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 OpenGL, be aware that setting OpenGL 3.x or 4.x specific states and leaving these enabled or set to non-default values when returning from the connected slot can interfere with the scene graph's rendering.
另請參閱 rendererInterface (), 場景圖形 - QML 下的 OpenGL , 場景圖形 - 在 QML 下的 Metal , 場景圖形 - 在 QML 下的 Vulkan ,和 場景圖形 - 在 QML 下的 Direct3D 11 .
[signal]
void
QQuickWindow::
beforeSynchronizing
()
This signal is emitted before the scene graph is synchronized with the QML state.
Even though the signal is emitted from the scene graph rendering thread, the GUI thread is guaranteed to be blocked, like it is in QQuickItem::updatePaintNode (). Therefore, it is safe to access GUI thread thread data in a slot or lambda that is connected with Qt::DirectConnection .
This signal can be used to do any preparation required before calls to QQuickItem::updatePaintNode ().
When using OpenGL, the QOpenGLContext used for rendering by the scene graph will be bound at this point.
警告: 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 OpenGL, be aware that setting OpenGL 3.x or 4.x specific states and leaving these enabled or set to non-default values when returning from the connected slot can interfere with the scene graph's rendering.
When mixing raw graphics (OpenGL, Vulkan, Metal, etc.) commands with scene graph rendering, it is necessary to call this function before recording commands to the command buffer used by the scene graph to render its main render pass. This is to avoid clobbering state.
在實踐中,此函數的調用經常是從槽連接到 beforeRenderPassRecording () 或 afterRenderPassRecording () 信號。
The function does not need to be called when recording commands to the application's own command buffer (such as, a VkCommandBuffer or MTLCommandBuffer + MTLRenderCommandEncoder created and managed by the application, not retrieved from the scene graph). With graphics APIs where no native command buffer concept is exposed (OpenGL, Direct 3D 11), beginExternalCommands() and endExternalCommands () together provide a replacement for the Qt 5 resetOpenGLState() function.
調用此函數和 endExternalCommands () 沒有必要在 render () implementation of a QSGRenderNode 因為場景圖形會為渲染節點,隱式履行必要步驟。
Native graphics objects (such as, graphics device, command buffer or encoder) are accessible via QSGRendererInterface::getResource ().
警告: Watch out for the fact that QSGRendererInterface::CommandListResource may return a different object between beginExternalCommands() - endExternalCommands (). This can happen when the underlying implementation provides a dedicated secondary command buffer for recording external graphics commands within a render pass. Therefore, always query CommandListResource after calling this function. Do not attempt to reuse an object from an earlier query.
注意: When the scenegraph is using OpenGL, pay attention to the fact that the OpenGL state in the context can have arbitrary settings, and this function does not perform any resetting of the state back to defaults.
另請參閱 endExternalCommands () 和 QQuickOpenGLUtils::resetOpenGLState ().
[override virtual protected]
void
QQuickWindow::
closeEvent
(
QCloseEvent
*
e
)
重實現: QWindow::closeEvent (QCloseEvent *ev).
創建簡單圖像節點。當場景圖形未初始化時,返迴值為 null。
This is cross-backend alternative to constructing a QSGSimpleTextureNode 直接。
另請參閱 QSGImageNode .
創建 9 個補丁節點。當場景圖形未初始化時,返迴值為 null。
創建簡單矩形節點。當場景圖形未初始化時,返迴值為 null。
This is cross-backend alternative to constructing a QSGSimpleRectNode 直接。
另請參閱 QSGRectangleNode .
創建新的 QSGTexture 從供給 image 。若圖像擁有 Alpha 通道,相應紋理將擁有 Alpha 通道。
The caller of the function is responsible for deleting the returned texture. The underlying native texture object is then destroyed together with the QSGTexture .
當 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.
When the scene graph uses OpenGL, the returned texture will be using
GL_TEXTURE_2D
作紋理目標和
GL_RGBA
as internal format. With other graphics APIs, the texture format is typically
RGBA8
。重實現
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 .
這是重載函數。
返迴用於此窗口的設備像素比率。
這不同於 QWindow::devicePixelRatio () in that it supports redirected rendering via QQuickRenderControl and QQuickRenderTarget 。當使用 QQuickRenderControl , QQuickWindow is often not fully 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. This function takes into account both QQuickRenderControl::renderWindowFor () 和 QQuickRenderTarget::devicePixelRatio (). When no redirection is in effect, the result is same as QWindow::devicePixelRatio ().
另請參閱 QQuickRenderControl , QQuickRenderTarget , setRenderTarget (),和 QWindow::devicePixelRatio ().
When mixing raw graphics (OpenGL, Vulkan, Metal, etc.) commands with scene graph rendering, it is necessary to call this function after recording commands to the command buffer used by the scene graph to render its main render pass. This is to avoid clobbering state.
在實踐中,此函數的調用經常是從槽連接到 beforeRenderPassRecording () 或 afterRenderPassRecording () 信號。
The function does not need to be called when recording commands to the application's own command buffer (such as, a VkCommandBuffer or MTLCommandBuffer + MTLRenderCommandEncoder created and managed by the application, not retrieved from the scene graph). With graphics APIs where no native command buffer concept is exposed (OpenGL, Direct 3D 11), beginExternalCommands () and endExternalCommands() together provide a replacement for the Qt 5 resetOpenGLState() function.
調用此函數和 beginExternalCommands () 沒有必要在 render () implementation of a QSGRenderNode 因為場景圖形會為渲染節點,隱式履行必要步驟。
另請參閱 beginExternalCommands () 和 QQuickOpenGLUtils::resetOpenGLState ().
[override virtual protected]
bool
QQuickWindow::
event
(
QEvent
*
event
)
重實現: QWindow::event (QEvent *ev).
[override virtual protected]
void
QQuickWindow::
exposeEvent
(
QExposeEvent
*)
重實現: QWindow::exposeEvent (QExposeEvent *ev).
[override virtual protected]
void
QQuickWindow::
focusInEvent
(
QFocusEvent
*
ev
)
重實現: QWindow::focusInEvent (QFocusEvent *ev).
[override virtual protected]
void
QQuickWindow::
focusOutEvent
(
QFocusEvent
*
ev
)
重實現: QWindow::focusOutEvent (QFocusEvent *ev).
[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.
此信號將從場景圖形渲染綫程中發射。
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.
注意:
When using this window in combination with
QQuickRenderControl
, the result of this function is an empty image, unless the
software
backend is in use. This is because when redirecting the output to an application-managed graphics resource (such as, a texture) by using
QQuickRenderControl
and
setRenderTarget
(), the application is better suited for managing and executing an eventual read back operation, since it is in full control of the resource to begin with.
警告: Calling this function will cause performance problems.
警告: 隻可以從 GUI 綫程是調用此函數。
[static, since 6.0]
QSGRendererInterface::GraphicsApi
QQuickWindow::
graphicsApi
()
Returns the graphics API that would be used by the scene graph if it was initialized at this point in time.
The standard way to query the API used by the scene graph is to use QSGRendererInterface::graphicsApi () once the scene graph has initialized, for example when or after the sceneGraphInitialized () signal is emitted. In that case one gets the true, real result, because then it is known that everything was initialized correctly using that graphics API.
This is not always convenient. If the application needs to set up external frameworks, or needs to work with setGraphicsDevice () in a manner that depends on the scene graph's built in API selection logic, it is not always feasiable to defer such operations until after the QQuickWindow has been made visible or QQuickRenderControl::initialize () 被調用。
Therefore, this static function is provided as a counterpart to setGraphicsApi (): it can be called at any time, and the result reflects what API the scene graph would choose if it was initialized at the point of the call.
注意: This static function is intended to be called on the main (GUI) thread only. For querying the API when rendering, use QSGRendererInterface since that object lives on the render thread.
注意: This function does not take scene graph backends into account.
該函數在 Qt 6.0 引入。
另請參閱 setGraphicsApi ().
[since 6.0]
QQuickGraphicsConfiguration
QQuickWindow::
graphicsConfiguration
() const
返迴 QQuickGraphicsDevice passed to setGraphicsDevice (), or a default constructed one otherwise
該函數在 Qt 6.0 引入。
另請參閱 setGraphicsConfiguration ().
[since 6.0]
QQuickGraphicsDevice
QQuickWindow::
graphicsDevice
() const
返迴 QQuickGraphicsDevice passed to setGraphicsDevice (), or a default constructed one otherwise
該函數在 Qt 6.0 引入。
另請參閱 setGraphicsDevice ().
返迴引用針對 GraphicsStateInfo struct describing some of the RHI's internal state, in particular, the double or tripple buffering status of the backend (such as, the Vulkan or Metal integrations). This is relevant when the underlying graphics APIs is Vulkan or Metal, and the external rendering code wishes to perform double or tripple buffering of its own often-changing resources, such as, uniform buffers, in order to avoid stalling the pipeline.
[static]
bool
QQuickWindow::
hasDefaultAlphaBuffer
()
Returns whether to use alpha transparency on newly created windows.
另請參閱 setDefaultAlphaBuffer ().
[override virtual protected]
void
QQuickWindow::
hideEvent
(
QHideEvent
*)
重實現: QWindow::hideEvent (QHideEvent *ev).
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.
Returns whether essential graphics resources can be released during the lifetime of the QQuickWindow .
注意: This is a hint, and is not guaranteed that it is taken into account.
另請參閱 setPersistentGraphics ().
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.
Returns true if the scene graph has been initialized; otherwise returns false.
[override virtual protected]
void
QQuickWindow::
keyPressEvent
(
QKeyEvent
*
e
)
重實現: QWindow::keyPressEvent (QKeyEvent *ev).
[override virtual protected]
void
QQuickWindow::
keyReleaseEvent
(
QKeyEvent
*
e
)
重實現: QWindow::keyReleaseEvent (QKeyEvent *ev).
[override virtual protected]
void
QQuickWindow::
mouseDoubleClickEvent
(
QMouseEvent
*
event
)
重實現: QWindow::mouseDoubleClickEvent (QMouseEvent *ev).
[override virtual protected]
void
QQuickWindow::
mouseMoveEvent
(
QMouseEvent
*
event
)
重實現: QWindow::mouseMoveEvent (QMouseEvent *ev).
[override virtual protected]
void
QQuickWindow::
mousePressEvent
(
QMouseEvent
*
event
)
重實現: QWindow::mousePressEvent (QMouseEvent *ev).
[override virtual protected]
void
QQuickWindow::
mouseReleaseEvent
(
QMouseEvent
*
event
)
重實現: QWindow::mouseReleaseEvent (QMouseEvent *ev).
[slot]
void
QQuickWindow::
releaseResources
()
此函數會試著釋放目前由 QML 場景保持的冗餘資源。
Calling this function requests the scene graph to release cached graphics resources, such as graphics pipeline objects, shader programs, or image data.
Additionally, depending on the render loop in use, this function may also result in the scene graph and all window-related rendering resources to be released. If this happens, the sceneGraphInvalidated () signal will be emitted, allowing users to clean up their own graphics resources. The setPersistentGraphics () 和 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.
注意: The releasing of cached graphics resources, such as graphics pipelines or shader programs is not dependent on the persistency hints. The releasing of those will happen regardless of the values of the persistent graphics and scenegraph hints.
注意: This function is not related to the QQuickItem::releaseResources () virtual function.
另請參閱 sceneGraphInvalidated (), setPersistentGraphics (),和 setPersistentSceneGraph ().
[since 6.0]
QQuickRenderTarget
QQuickWindow::
renderTarget
() const
返迴 QQuickRenderTarget passed to setRenderTarget (), or a default constructed one otherwise
該函數在 Qt 6.0 引入。
另請參閱 setRenderTarget ().
返迴當前渲染器接口。值始終有效且從不為 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.
另請參閱 QSGRenderNode and QSGRendererInterface .
[override virtual protected]
void
QQuickWindow::
resizeEvent
(
QResizeEvent
*
ev
)
重實現: QWindow::resizeEvent (QResizeEvent *ev).
[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.
另請參閱 sceneGraphInvalidated ().
[static]
QString
QQuickWindow::
sceneGraphBackend
()
返迴請求的 Qt Quick 場景圖形後端。
注意: 此函數的返迴值可能仍過時通過後續調用 setSceneGraphBackend () 直到第一 QQuickWindow 在應用程序中已構造。
注意:
The value only reflects the request in the
QT_QUICK_BACKEND
environment variable after a
QQuickWindow
has been constructed.
另請參閱 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.
此信號將從 GUI 綫程中發射。
[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.
When rendering with OpenGL, the QOpenGLContext 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.
此信號將從場景圖形渲染綫程中發射。
調度 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 the window is not exposed, and is not renderable, at the time the job is either posted or handled, the job is deleted without executing the run() method. If a non-threaded renderer is in use, the run() method of the job is executed synchronously. When rendering with OpenGL, the OpenGL context is changed to the renderer's context before executing any job, including NoStage jobs.
注意: 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 ();
另請參閱 beforeRendering (), afterRendering (), beforeSynchronizing (), afterSynchronizing (), frameSwapped (),和 sceneGraphInvalidated ().
[static]
void
QQuickWindow::
setDefaultAlphaBuffer
(
bool
useAlpha
)
useAlpha 指定是否在新近創建的窗口中使用 Alpha 透明度。
在任何期望創建半透明窗口的應用程序中,有必要將此設為 true 先於創建第一 QQuickWindow 。默認值為 false。
另請參閱 hasDefaultAlphaBuffer ().
[static, since 6.0]
void
QQuickWindow::
setGraphicsApi
(
QSGRendererInterface::GraphicsApi
api
)
Requests the specified graphics api .
When the built-in, default graphics adaptation is used,
api
specifies which graphics API (OpenGL, Vulkan, Metal, or Direct3D) the scene graph should use to render. In addition, the
software
backend is built-in as well, and can be requested by setting
api
to
QSGRendererInterface::Software
.
不像 setSceneGraphBackend (), which can only be used to request a given backend (shipped either built-in or installed as dynamically loaded plugins), this function works with the higher level concept of graphics APIs. It covers the backends that ship with Qt Quick, and thus have corresponding values in the QSGRendererInterface::GraphicsApi 枚舉。
When this function is not called at all, and the equivalent environment variable
QSG_RHI_BACKEND
is not set either, the scene graph will choose the graphics API to use based on the platform.
This function becomes important in applications that are only prepared for rendering with a given API. For example, if there is native OpenGL or Vulkan rendering done by the application, it will want to ensure Qt Quick is rendering using OpenGL or Vulkan too. Such applications are expected to call this function early in their main() function.
注意: 函數調用的發生必須先於構造第一 QQuickWindow in the application. The graphics API cannot be changed afterwards.
注意: 當組閤使用同 QQuickRenderControl , this rule is relaxed: it is possible to change the graphics API, but only when all existing QQuickRenderControl and QQuickWindow instances have been destroyed.
To query what graphics API the scene graph is using to render, QSGRendererInterface::graphicsApi () after the scene graph has initialized , which typically happens either when the window becomes visible for the first time, or when QQuickRenderControl::initialize () 被調用。
To switch back to the default behavior, where the scene graph chooses a graphics API based on the platform and other conditions, set api to QSGRendererInterface::Unknown .
該函數在 Qt 6.0 引入。
另請參閱 graphicsApi ().
[since 6.0]
void
QQuickWindow::
setGraphicsConfiguration
(const
QQuickGraphicsConfiguration
&
config
)
Sets the graphics configuration for this window. config contains various settings that may be taken into account by the scene graph when initializing the underlying graphics devices and contexts.
Such additional configuration, specifying for example what device extensions to enable for Vulkan, becomes relevant and essential when integrating native graphics rendering code that relies on certain extensions. The same is true when integrating with an external 3D or VR engines, such as OpenXR.
注意: The configuration is ignored when adopting existing graphics devices via setGraphicsDevice () since the scene graph is then not in control of the actual construction of those objects.
QQuickGraphicsConfiguration instances are implicitly shared, copyable, and can be passed by value.
警告: Setting a QQuickGraphicsConfiguration 在 QQuickWindow must happen early enough, before the scene graph is initialized for the first time for that window. With on-screen windows this means the call must be done before invoking show () on the QQuickWindow or QQuickView 。采用 QQuickRenderControl the configuration must be finalized before calling initialize ().
該函數在 Qt 6.0 引入。
另請參閱 graphicsConfiguration ().
[since 6.0]
void
QQuickWindow::
setGraphicsDevice
(const
QQuickGraphicsDevice
&
device
)
Sets the graphics device objects for this window. The scenegraph will use existing device, physical device, and other objects specified by device instead of creating new ones.
This function is very often used in combination with QQuickRenderControl and setRenderTarget (), in order to redirect Qt Quick rendering into a texture.
A default constructed
QQuickGraphicsDevice
does not change the default behavior in any way. Once a
device
created via one of the
QQuickGraphicsDevice
factory functions, such as,
QQuickGraphicsDevice::fromDeviceObjects
(), is passed in, and the scenegraph uses a matching graphics API (with the example of fromDeviceObjects(), that would be Vulkan), the scenegraph will use the existing device objects (such as, the
VkPhysicalDevice
,
VkDevice
, and graphics queue family index, in case of Vulkan) encapsulated by the
QQuickGraphicsDevice
. This allows using the same device, and so sharing resources, such as buffers and textures, between Qt Quick and native rendering engines.
警告: This function can only be called before initializing the scenegraph and will have no effect if called afterwards. In practice this typically means calling it right before QQuickRenderControl::initialize ().
As an example, this time with Direct3D, the typical usage is expected to be the following:
// native graphics resources set up by a custom D3D rendering engine ID3D11Device *device; ID3D11DeviceContext *context; ID3D11Texture2D *texture; ... // now to redirect Qt Quick content into 'texture' we could do the following: QQuickRenderControl *renderControl = new QQuickRenderControl; QQuickWindow *window = new QQuickWindow(renderControl); // this window will never be shown on-screen ... window->setGraphicsDevice(QQuickGraphicsDevice::fromDeviceAndContext(device, context)); renderControl->initialize(); window->setRenderTarget(QQuickRenderTarget::fromD3D11Texture(texture, textureSize); ...
The key aspect of using this function is to ensure that resources or handles to resources, such as
texture
in the above example, are visible to and usable by both the external rendering engine and the scenegraph renderer. This requires using the same graphics device (or with OpenGL, OpenGL context).
QQuickGraphicsDevice instances are implicitly shared, copyable, and can be passed by value. They do not own the associated native objects (such as, the ID3D11Device in the example).
注意: 使用 QQuickRenderControl does not always imply having to call this function. When adopting an existing device or context is not needed, this function should not be called, and the scene graph will then initialize its own devices and contexts normally, just as it would with an on-screen QQuickWindow .
該函數在 Qt 6.0 引入。
另請參閱 graphicsDevice (), QQuickRenderControl , setRenderTarget (),和 setGraphicsApi ().
Sets whether the graphics resources (graphics device or context, swapchain, buffers, textures) should be preserved, and cannot be released until the last window is deleted, to persistent 。默認值為 true。
When calling releaseResources (), or when the window gets hidden (more specifically, not renderable), some render loops have the possibility to release all, not just the cached, graphics resources. This can free up memory temporarily, but it also means the rendering engine will have to do a full, potentially costly reinitialization of the resources when the window needs to render again.
注意: The rules for when a window is not renderable are platform and window manager specific.
注意: All graphics resources are released when the last QQuickWindow is deleted, regardless of this setting.
注意: This is a hint, and is not guaranteed that it is taken into account.
注意: This hint does not apply to cached resources, that are relatively cheap to drop and then recreate later. Therefore, calling releaseResources () will typically lead to releasing those regardless of the value of this hint.
另請參閱 isPersistentGraphics (), setPersistentSceneGraph (), sceneGraphInitialized (), sceneGraphInvalidated (),和 releaseResources ().
Sets whether the scene graph nodes and resources are
persistent
. Persistent means the nodes and resources cannot be released. The default value is
true
.
When calling releaseResources (), when the window gets hidden (more specifically, not renderable), some render loops have the possibility to release the scene graph nodes and related graphics resources. This frees up memory temporarily, but will also mean the scene graph has to be rebuilt when the window renders next time.
注意: The rules for when a window is not renderable are platform and window manager specific.
注意: The scene graph nodes and resources are always released when the last QQuickWindow is deleted, regardless of this setting.
注意: This is a hint, and is not guaranteed that it is taken into account.
另請參閱 isPersistentSceneGraph (), setPersistentGraphics (), sceneGraphInvalidated (), sceneGraphInitialized (),和 releaseResources ().
[since 6.0]
void
QQuickWindow::
setRenderTarget
(const
QQuickRenderTarget
&
target
)
將用於此窗口的渲染目標設為 target .
A QQuickRenderTarget serves as an opaque handle for a renderable native object, most commonly a 2D texture, and associated metadata, such as the size in pixels.
A default constructed QQuickRenderTarget means no redirection. A valid target , created via one of the static QQuickRenderTarget factory functions, on the other hand, enables redirection of the rendering of the Qt Quick scene: it will no longer target the color buffers for the surface associated with the window, but rather the textures or other graphics objects specified in target .
For example, assuming the scenegraph is using Vulkan to render, one can redirect its output into a
VkImage
. For graphics APIs like Vulkan, the image layout must be provided as well.
QQuickRenderTarget
instances are implicitly shared and are copyable and can be passed by value. They do not own the associated native objects (such as, the VkImage in the example), however.
QQuickRenderTarget rt = QQuickRenderTarget::fromVulkanImage(vulkanImage, VK_IMAGE_LAYOUT_PREINITIALIZED, pixelSize); quickWindow->setRenderTarget(rt);
This function is very often used in combination with QQuickRenderControl and an invisible QQuickWindow , in order to render Qt Quick content into a texture, without creating an on-screen native window for this QQuickWindow .
When the desired target, or associated data, such as the size, changes, call this function with a new QQuickRenderTarget . Constructing QQuickRenderTarget instances and calling this function is cheap, but be aware that setting a new target with a different native object or other data may lead to potentially expensive initialization steps when the scenegraph is about to render the next frame. Therefore change the target only when necessary.
注意: The window does not take ownership of any native objects referenced in target .
注意: It is the caller's responsibility to ensure the native objects referred to in target are valid for the scenegraph renderer too. For instance, with Vulkan, Metal, and Direct3D this implies that the texture or image is created on the same graphics device that is used by the scenegraph internally. Therefore, when texture objects created on an already existing device or context are involved, this function is often used in combination with setGraphicsDevice ().
注意:
With graphics APIs where relevant, the application must pay attention to image layout transitions performed by the scenegraph. For example, once a VkImage is associated with the scenegraph by calling this function, its layout will transition to
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
when rendering a frame.
警告: 隻可以從做渲染的綫程中調用此函數。
該函數在 Qt 6.0 引入。
另請參閱 renderTarget (), QQuickRenderControl , setGraphicsDevice (),和 setGraphicsApi ().
[static]
void
QQuickWindow::
setSceneGraphBackend
(const
QString
&
backend
)
Requests a Qt Quick scenegraph backend 。後端要麼可以是內置的,要麼以動態加載插件的形式安裝。
這是重載函數。
注意: 函數調用的發生必須先於構造第一 QQuickWindow 在應用程序中。之後無法改變。
見 Switch Between Adaptations in Your Application for more information about the list of backends. If backend is invalid or an error occurs, the request is ignored.
注意:
調用此函數相當於設置
QT_QUICK_BACKEND
or
QMLSCENE_DEVICE
環境變量。不管怎樣,在卵生其它進程的應用程序中使用此 API 更安全,因為不需要擔心環境繼承。
另請參閱 sceneGraphBackend ().
[static]
void
QQuickWindow::
setTextRenderType
(
QQuickWindow::TextRenderType
renderType
)
將 Qt Quick 中像文本元素的默認渲染類型設為 renderType .
注意: 設置渲染類型僅影響之後創建的元素;不會修改現有元素的渲染類型。
另請參閱 textRenderType ().
[override virtual protected]
void
QQuickWindow::
showEvent
(
QShowEvent
*)
重實現: QWindow::showEvent (QShowEvent *ev).
[override virtual protected]
void
QQuickWindow::
tabletEvent
(
QTabletEvent
*
event
)
重實現: QWindow::tabletEvent (QTabletEvent *ev).
[static]
QQuickWindow::TextRenderType
QQuickWindow::
textRenderType
()
返迴 Qt Quick 中像文本元素的渲染類型。默認為 QQuickWindow::QtTextRendering .
另請參閱 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 (QWheelEvent *ev).