QQuickRenderControl OpenGL の例

Qt Quick シーンをテクスチャにレンダリングして、Quick ベースでない OpenGL レンダラーで使用する方法を示します。

Qt Quick シーンは、QQuickWindow によって管理され、画面上には表示されません。むしろ、レンダリングは OpenGL テクスチャをターゲットとし、QQuickRenderControl を介して制御されます。

キューブは、QWindowQOpenGLContextQOpenGLShaderProgramQOpenGLFunctions などの Qt GUI イネーブラを使用して、OpenGL で直接レンダリングされます。キューブは、Qt Quick のレンダーパスが出力するテクスチャでテクスチャされます。

さらに、基本的な入力イベント転送も実演しています。マウスの左ボタンを押し続けると、Rectangle の背景色が QML バインディングによって変更されます。同様に、キーボードのキーを押し続けると、色も変わります。これは、アプリケーションから送信された「偽」のイベント(画面上のQWindow からのイベントに基づいて生成されたもの)が転送され、Qt Quick シーン内で処理されることを証明しています。

プロジェクト例 @ code.qt.io

© 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.