QQuickRenderControl OpenGL 示例
演示如何将Qt Quick 场景渲染到纹理中,然后由非基于Quick的OpenGL渲染器使用该纹理。

该Qt Quick 场景由一个QQuickWindow 管理,该对象在屏幕上不可见。渲染目标为一个OpenGL纹理,并通过QQuickRenderControl 进行控制。
该立方体直接通过 OpenGL 渲染,使用了诸如QWindow 、QOpenGLContext 、QOpenGLShaderProgram 和QOpenGLFunctions 等 Qt GUI 启用器。立方体的纹理来自Qt Quick 渲染通道输出的纹理。
此外,还演示了基本的输入事件转发功能。当按住鼠标左键时,通过 QML 绑定会改变背景色Rectangle 。 同样地,按住键盘上的某个键也会改变颜色。这证明了应用程序发送的“模拟”事件(基于屏幕上QWindow 产生的事件生成)会在Qt Quick 场景中被转发并处理。
© 2026 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.