QGraphicsTransform Class
QGraphicsTransform クラスは、QGraphicsItem に対して高度な変形を適用するための抽象基底クラスです。詳細...
| ヘッダー: | #include <QGraphicsTransform> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
| qmake: | QT += widgets |
| 継承元: | QObject |
| 継承元: |
パブリック関数
| QGraphicsTransform(QObject *parent = nullptr) | |
| virtual | ~QGraphicsTransform() |
| virtual void | applyTo(QMatrix4x4 *matrix) const = 0 |
プロテクトされたスロット
| void | update() |
詳細な説明
QGraphicsItem::transform の代替として、QGraphicsTransform を使用すると、専用のプロパティを使用して個別に設定できる高度な変形を作成および制御することができます。
QGraphicsItem を使用すると、1 つのQGraphicsItem に任意の数の QGraphicsTransform インスタンスを割り当てることができます。各 QGraphicsTransform は、割り当てられたQGraphicsItem に対して、順番に 1 つずつ適用されます。
QGraphicsTransformは、アニメーションにおいて特に有用です。QGraphicsItem::setTransform()を使用すると、任意のトランスフォームをアイテムに直接割り当てることができますが、2つの異なるトランスフォーム間を補間する直接的な方法はありません(例えば、アイテムにそれぞれ異なる任意のトランスフォームが割り当てられている2つの状態間の遷移時など)。 QGraphicsTransform を使用すると、各独立した変換のプロパティ値を補間することができます。その結果得られる操作は、単一の変換に統合され、QGraphicsItem に適用されます。
変換は、QMatrix4x4 を使用して真の3D空間で計算されます。変換がQGraphicsItem に適用されると、2DのQTransform へと投影されます。 複数の QGraphicsTransform オブジェクトがQGraphicsItem に適用される場合、すべての変換は真の 3D 空間で計算され、2D への投影は最後の QGraphicsTransform が適用された後にのみ行われます。ただし、QGraphicsRotation は例外であり、X 軸および Y 軸周りの遠近感を維持するために、各回転の後に 2D へ投影されます。
独自の設定可能な変換を作成したい場合は、QGraphicsTransform(または既存のサブクラスのいずれか)のサブクラスを作成し、QMatrix4x4 へのポインタを引数とする純仮想関数applyTo()を再実装します。 適用したい各操作は、プロパティとして公開する必要があります(例:customTransform->setVerticalShear(2.5))。applyTo() の再実装内では、渡された変換を適宜変更することができます。
QGraphicsTransformは、QGraphicsItem::setTransform()、QGraphicsItem::setRotation()、およびQGraphicsItem::setScale()と組み合わせて使用できます。
QGraphicsItem::transform()、QGraphicsScale 、およびQGraphicsRotationも参照してください 。
メンバ関数のドキュメント
QGraphicsTransform::QGraphicsTransform(QObject *parent = nullptr)
指定されたparent を使用して、新しいQGraphicsTransformを構築します。
[virtual noexcept] QGraphicsTransform::~QGraphicsTransform()
グラフィック変換を破棄します。
[pure virtual] void QGraphicsTransform::applyTo(QMatrix4x4 *matrix) const
この純粋仮想メソッドは、派生クラスで再実装する必要があります。
この変換は、matrix に対して適用されます。
QGraphicsItem::transform() およびQMatrix4x4::toTransform()も参照してください 。
[protected slot] void QGraphicsTransform::update()
この変換操作のパラメータが変更され、applyTo() が以前とは異なる結果を返すようになったことを通知します。
独自のグラフィック変換を実装する際は、パラメータを変更するたびにこの関数を呼び出し、QGraphicsItem に対して変換の更新が必要であることを通知する必要があります。
applyTo()も参照してください 。
© 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.