QQuickWidget - QQuickView比较示例
展示了QQuickWidget 与作为本地窗口嵌入的QQuickView 相比的优势。
该示例允许使用两种不同的方法在基于QWidget 的用户界面中显示相同的Qt Quick 场景:一种是使用QQuickView 并将其作为子窗口和QWidget::createWindowContainer() 使用。另一种是使用QQuickWidget ,作为真正的QWidget ,除其他外,支持更好的剪切和堆叠,正如真正的QWidget 所期望的那样。
Qt Quick 场景也使用直接 OpenGL 渲染,证明QQuickWidget 的渲染仍然使用加速 3D API。这意味着该示例与 OpenGL 绑定,无法使用其他图形 API(Vulkan、Metal、Direct 3D)。
点击 "显示叠加 "复选框演示了一个部件堆叠案例,当嵌入本地窗口时,该案例无法按预期进行渲染,而通过QQuickWidget 则可以按预期进行渲染。
还可以使用多采样抗锯齿功能。当通过相应复选框启用多采样抗锯齿时,QQuickWidget 将在内部渲染到多采样渲染缓冲区,然后在每次渲染后将其解析为普通的非多采样 2D 纹理,这样就可以在不影响QWidget UI 其他部分的情况下为Qt Quick 内容启用多采样。通过QQuickView ,本机窗口将请求对其相应的窗口表面进行多重采样,如果平台支持,也会带来类似的结果。
Qt Quick 场景是交互式的:无论使用哪种嵌入技术,都可以在文本字段中输入内容。QQuickWidget 会自动将输入事件转发至底层Qt Quick 场景。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.