QGraphicsRotation Class
QGraphicsRotation クラスは、指定された軸を中心とした回転変換を提供します。詳細...
| ヘッダー: | #include <QGraphicsRotation> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
| qmake: | QT += widgets |
| 継承元: | QGraphicsTransform |
プロパティ
パブリック関数
| QGraphicsRotation(QObject *parent = nullptr) | |
| virtual | ~QGraphicsRotation() |
| qreal | angle() const |
| QVector3D | axis() const |
| QVector3D | origin() const |
| void | setAngle(qreal) |
| void | setAxis(const QVector3D &axis) |
| void | setAxis(Qt::Axis axis) |
| void | setOrigin(const QVector3D &point) |
再実装されたパブリック関数
| virtual void | applyTo(QMatrix4x4 *matrix) const override |
シグナル
| void | angleChanged() |
| void | axisChanged() |
| void | originChanged() |
詳細な説明
axis プロパティにQVector3D を割り当てるか、setAxis 便利関数にQt::Axis を引数として渡すことで、目的の軸を指定できます。デフォルトでは、軸は (0, 0, 1)、つまり Z 軸を中心とした回転となります。
QGraphicsRotation が提供する angle プロパティは、この軸を中心に回転させる角度(度単位)を表します。
QGraphicsRotation は、回転の適用方法を制御するための特定のパラメータを提供します。
原点とは、アイテムが回転する中心となる点のことです(つまり、アイテムの残りの部分が回転しても、原点は親要素に対して固定されたままになります)。デフォルトでは、原点はQPointF(0, 0) です。
angle プロパティは、原点を中心にアイテムを時計回りに回転させる角度(度)を指定します。この値は負の数にすることも可能で、その場合は反時計回りの回転を表します。アニメーションの目的では、(-360, 360) 度を超える回転角度を指定することも有用です。例えば、アイテムが数回回転する様子をアニメーション化する場合などが挙げられます。
注:最終的な回転は、3D空間での回転と、それに続く2Dへの投影の複合的な効果となります。複数の回転が連続して行われる場合、それらがすべてZ軸周りの回転でない限り、期待どおりの挙動にはなりません。
関連項目: QGraphicsTransform 、QGraphicsItem::setRotation()、およびQTransform::rotate()。
プロパティのドキュメント
angle : qreal
このプロパティは、時計回りの回転角度(度単位)を保持します。
角度には任意の実数を指定できます。デフォルト値は 0.0 です。180 を指定すると、時計回りに 180 度回転します。負の数を指定すると、アイテムは反時計回りに回転します。 通常、回転角度は (-360, 360) の範囲内ですが、この範囲外の数値を指定することも可能です(例えば、370 度の角度は 10 度と同じ結果になります)。角度を NaN に設定すると、回転は行われません。
アクセス関数:
| qreal | angle() const |
| void | setAngle(qreal) |
通知シグナル:
| void | angleChanged() |
「origin」も参照してください 。
axis : QVector3D
このプロパティは、3D空間内のベクトルによって指定される回転軸を保持します。
これは3D空間内の任意の軸にすることができます。 デフォルトでは、軸は (0, 0, 1) であり、これは Z 軸と一致します。別の軸を指定すると、QGraphicsRotation はこの軸を中心に回転する変換を返します。たとえば、アイテムを X 軸を中心に回転させたい場合は、軸として (1, 0, 0) を渡すことができます。
アクセス関数:
| QVector3D | axis() const |
| void | setAxis(const QVector3D &axis) |
| void | setAxis(Qt::Axis axis) |
通知シグナル:
| void | axisChanged() |
関連項目: QTransform およびQGraphicsRotation::angle 。
origin : QVector3D
このプロパティは、3D空間における回転の原点を保持します。
すべての回転はこの点を基準に行われます(つまり、アイテムが回転する際、この点は親要素に対して固定されたままになります)。
アクセス関数:
| QVector3D | origin() const |
| void | setOrigin(const QVector3D &point) |
通知シグナル:
| void | originChanged() |
関連項目: angle 。
メンバ関数のドキュメント
QGraphicsRotation::QGraphicsRotation(QObject *parent = nullptr)
指定されたparent を使用して、新しいQGraphicsRotationを生成します。
[virtual noexcept] QGraphicsRotation::~QGraphicsRotation()
グラフィックの回転を解除します。
[signal] void QGraphicsRotation::angleChanged()
このシグナルは、角度が変化した際に発せられます。
注: プロパティ `angle` に関する通知 信号です。
「QGraphicsRotation::angle」も参照してください 。
[override virtual] void QGraphicsRotation::applyTo(QMatrix4x4 *matrix) const
QGraphicsTransform::applyTo(QMatrix4x4 *matrix) const の再実装。
[signal] void QGraphicsRotation::axisChanged()
このシグナルは、オブジェクトの軸が変更されるたびに発生します。
注: プロパティ `axis` に対する通知 シグナルです。
「QGraphicsRotation::axis」も参照してください 。
[signal] void QGraphicsRotation::originChanged()
このシグナルは、プロパティの起源が変更されるたびに発火します。
注: プロパティ「origin」の通知 シグナルです。
QGraphicsRotation::originも参照してください 。
void QGraphicsRotation::setAxis(Qt::Axis axis)
軸をaxis に設定するための便利な機能です。
注:QTransform における `Qt::YAxis ` による回転は、3D 空間における正しい数学的回転とは逆になります。QGraphicsRotation クラスは、正しい数学的回転を実装しています。以下の 2 つのコードは、同じ変換を実行します:
QTransform t;
t.rotate(45, Qt::YAxis);
QGraphicsRotation r;
r.setAxis(Qt::YAxis);
r.setAngle(-45);注: プロパティ `axis`のセッター 関数。
axis()も参照してください 。
© 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.