QQuickFramebufferObject Class
QQuickFramebufferObject クラスは、フレームバッファオブジェクト(FBO)を使用した OpenGL レンダリングを、Qt Quick と統合するための利便性向上のためのクラスです。続きを読む...
| ヘッダー: | #include <QQuickFramebufferObject> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Quick) target_link_libraries(mytarget PRIVATE Qt6::Quick) |
| qmake: | QT += quick |
| 継承元: | QQuickItem |
パブリック型
| class | Renderer |
プロパティ
- mirrorVertically : bool
- textureFollowsItemSize : bool
パブリック関数
| QQuickFramebufferObject(QQuickItem *parent = nullptr) | |
| virtual QQuickFramebufferObject::Renderer * | createRenderer() const = 0 |
| bool | mirrorVertically() const |
| void | setMirrorVertically(bool enable) |
| void | setTextureFollowsItemSize(bool follows) |
| bool | textureFollowsItemSize() const |
再実装されたパブリック関数
| virtual bool | isTextureProvider() const override |
| virtual void | releaseResources() override |
| virtual QSGTextureProvider * | textureProvider() const override |
シグナル
| void | mirrorVerticallyChanged(bool) |
| void | textureFollowsItemSizeChanged(bool) |
詳細な説明
警告: このクラスは 、Qt Quick がOpenGLを介してレンダリングを行っている場合にのみ機能します。VulkanやMetalなどの他のグラフィックスAPIとは互換性がありません。これは、Qt 5アプリケーションがOpenGLに依存している限り、ソース互換性を損なうことなく動作できるようにするためにのみ存在するレガシークラスとして扱う必要があります。
ほとんどのプラットフォームでは、レンダリングは専用のスレッドで行われます。このため、QQuickFramebufferObject クラスは、アイテムの実装と FBO レンダリングの間で厳格な分離を強制します。 プロパティやQMLで必要なUI関連のヘルパー関数など、すべてのアイテムロジックはQQuickFramebufferObjectクラスのサブクラスに配置する必要があります。レンダリングに関連するすべての処理は、QQuickFramebufferObject::Renderer クラス内に配置しなければなりません。
2つのスレッド間でのレースコンディションや読み書きの問題を回避するため、レンダラーとアイテムが共有変数を読み書きしないことが重要です。アイテムとレンダラー間の通信は、主にQQuickFramebufferObject::Renderer::synchronize()関数を介して行われるべきです。この関数は、GUIスレッドがブロックされている間に、レンダリングスレッド上で呼び出されます。
アイテムとレンダラー間の通信に、キュー化された接続やイベントを使用することも可能です。
Renderer と FBO は、どちらも内部でメモリ管理が行われます。
FBO へレンダリングするには、ユーザーは Renderer クラスをサブクラス化し、そのRenderer::render() 関数を再実装する必要があります。Renderer サブクラスは、createRenderer() から返されます。
FBO のサイズは、デフォルトではアイテムのサイズに合わせて調整されます。固定サイズを希望する場合は、textureFollowsItemSize をfalse に設定し、QQuickFramebufferObject::Renderer::createFramebufferObject() から任意のテクスチャを返してください。
Qt 5.4 以降、QQuickFramebufferObject クラスはtexture provider であり、ShaderEffects や、テクスチャプロバイダを利用するその他のクラスで直接使用できます。
「シーングラフ」および「レンダリング」も参照してください 。
プロパティのドキュメント
mirrorVertically : bool
このプロパティは、描画時にFBOの内容のサイズを垂直方向に反転させるかどうかを制御します。これにより、標準的な仕様とは異なるサードパーティ製のレンダリングコードを容易に統合することができます。
デフォルト値はfalse です。
アクセス関数:
| bool | mirrorVertically() const |
| void | setMirrorVertically(bool enable) |
通知シグナル:
| void | mirrorVerticallyChanged(bool) |
textureFollowsItemSize : bool
このプロパティは、FBOのテクスチャのサイズを「QQuickFramebufferObject 」項目の寸法に合わせて設定するかどうかを制御します。このプロパティがfalseの場合、FBOは最初に表示された際に一度だけ作成されます。trueに設定されている場合、項目の寸法が変更されるたびにFBOが再作成されます。
デフォルト値は `true` です。
アクセス関数:
| bool | textureFollowsItemSize() const |
| void | setTextureFollowsItemSize(bool follows) |
通知シグナル:
| void | textureFollowsItemSizeChanged(bool) |
メンバ関数のドキュメント
QQuickFramebufferObject::QQuickFramebufferObject(QQuickItem *parent = nullptr)
親オブジェクトとしてparent を持つ新しいQQuickFramebufferObjectを構築します。
[pure virtual] QQuickFramebufferObject::Renderer *QQuickFramebufferObject::createRenderer() const
この関数を再実装して、FBO への描画に使用されるレンダラーを作成してください。
この関数は、GUIスレッドがブロックされている間に、レンダリングスレッドから呼び出されます。
[override virtual] bool QQuickFramebufferObject::isTextureProvider() const
QQuickItem::isTextureProvider() const を再実装します。
[override virtual] void QQuickFramebufferObject::releaseResources()
QQuickItem::releaseResources() を再実装しています。
[override virtual] QSGTextureProvider *QQuickFramebufferObject::textureProvider() const
QQuickItem::textureProvider() const を再実装します。
© 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.