このページでは

QCustom3DItem Class

QCustom3DItem クラスは、グラフにカスタム項目を追加します。詳細...

ヘッダー: #include <QCustom3DItem>
CMake: find_package(Qt6 REQUIRED COMPONENTS Graphs)
target_link_libraries(mytarget PRIVATE Qt6::Graphs)
qmake: QT += graphs
QML内: Custom3DItem
継承元: QObject
継承元:

QCustom3DLabel およびQCustom3DVolume

プロパティ

パブリック関数

QCustom3DItem(QObject *parent = nullptr)
QCustom3DItem(const QString &meshFile, QVector3D position, QVector3D scaling, const QQuaternion &rotation, const QImage &texture, QObject *parent = nullptr)
virtual ~QCustom3DItem() override
bool isPositionAbsolute() const
bool isRotationAbsolute() const
bool isScalingAbsolute() const
bool isShadowCasting() const
bool isVisible() const
QString meshFile() const
QVector3D position() const
QQuaternion rotation()
QVector3D scaling() const
void setMeshFile(const QString &meshFile)
void setPosition(QVector3D position)
void setPositionAbsolute(bool positionAbsolute)
void setRotation(const QQuaternion &rotation)
void setRotationAbsolute(bool rotationAbsolute)
void setRotationAxisAndAngle(QVector3D axis, float angle)
void setScaling(QVector3D scaling)
void setScalingAbsolute(bool scalingAbsolute)
void setShadowCasting(bool enabled)
void setTextureFile(const QString &textureFile)
void setTextureImage(const QImage &textureImage)
void setVisible(bool visible)
QString textureFile() const

シグナル

void meshFileChanged(const QString &meshFile)
void positionAbsoluteChanged(bool positionAbsolute)
void positionChanged(QVector3D position)
void rotationAbsoluteChanged(bool newRotationAbsolute)
void rotationChanged(const QQuaternion &rotation)
void scalingAbsoluteChanged(bool scalingAbsolute)
void scalingChanged(QVector3D scaling)
void shadowCastingChanged(bool shadowCasting)
void textureFileChanged(const QString &textureFile)
void visibleChanged(bool visible)

詳細な説明

カスタムアイテムには、カスタムメッシュ、位置、スケール、回転、およびオプションのテクスチャがあります。

関連項目: Q3DGraphsWidgetItem::addCustomItem()。

プロパティのドキュメント

meshFile : QString

このプロパティには、アイテムのメッシュファイル名が格納されます。

ファイル内のアイテムはメッシュ形式である必要があります。その他の形式は、Balsamアセットインポートツールを使用して変換可能です。メッシュファイルには、頂点、法線、UV座標を含めることを推奨します。

アクセス関数:

QString meshFile() const
void setMeshFile(const QString &meshFile)

通知シグナル:

void meshFileChanged(const QString &meshFile)

position : QVector3D

このプロパティは、アイテムの位置をQVector3D として保持します。

デフォルトはQVector3D(0.0, 0.0, 0.0) です。

項目の位置は、positionAbsolute プロパティに応じて、データ座標または絶対座標のいずれかで指定されます。絶対座標を使用する場合、-1.0...1.0 の範囲内の値が軸の範囲内となります。

注: positionAbsolute がfalse に設定されている場合、軸の範囲外に配置されたアイテムは レンダリングされません。ただし、そのアイテムが部分的に表示されるQCustom3DVolume であり、かつscalingAbsolute もfalse に設定されている場合は例外です。その場合、ボリュームの可視部分がレンダリングされます。

アクセス関数:

QVector3D position() const
void setPosition(QVector3D position)

通知シグナル:

void positionChanged(QVector3D position)

positionAbsoluteも参照してください 。

positionAbsolute : bool

このプロパティは、項目の位置をデータ座標で扱うか、絶対座標で扱うかを指定します。

デフォルトはfalse です。絶対座標を持つアイテムは常にレンダリングされますが、データ座標を持つアイテムは軸の範囲内にある場合にのみレンダリングされます。

アクセス関数:

bool isPositionAbsolute() const
void setPositionAbsolute(bool positionAbsolute)

通知シグナル:

void positionAbsoluteChanged(bool positionAbsolute)

「position」も参照してください 。

rotation : QQuaternion

このプロパティは、アイテムの回転をQQuaternion として保持します。

デフォルト値はQQuaternion(0.0, 0.0, 0.0, 0.0) です。

アクセス関数:

QQuaternion rotation()
void setRotation(const QQuaternion &rotation)

通知シグナル:

void rotationChanged(const QQuaternion &rotation)

[since 6.11] rotationAbsolute : bool

このプロパティは、アイテムの回転をデータ軸座標で処理するか、絶対座標で処理するかを指定します。

アイテムの回転をデータ値で処理するか、絶対値で処理するかを定義します。デフォルトはtrue です。絶対回転を持つアイテムは、軸に関係なくデフォルトの座標で回転します。データ回転を持つアイテムは、軸の座標に従って回転します。

この列挙型はQt 6.11で導入されました。

アクセス関数:

bool isRotationAbsolute() const
void setRotationAbsolute(bool rotationAbsolute)

通知シグナル:

void rotationAbsoluteChanged(bool newRotationAbsolute)

「rotation」も参照してください 。

scaling : QVector3D

このプロパティは、項目のスケーリングをQVector3D として保持します。

デフォルトはQVector3D(0.1, 0.1, 0.1) です。

項目のスケーリングは、scalingAbsolute プロパティに応じて、データ値または絶対値のいずれかで行われます。絶対値として解釈されるデフォルトのベクトルは、項目のメッシュが正規化されており、グラフのアスペクト比がデフォルトから変更されていない場合、項目をグラフの高さの 10% に設定します。

注: Qt 6.8では 、モデルは実際にはサイズ 2 (-1...1) にスケーリングされているにもかかわらず、デフォルトでサイズ 1 (-0.5...0.5) にスケーリングされていると誤って想定されていました。 このため、Qt 6.9以降のすべてのカスタムアイテムは、Qt 6.8と比較して2倍のサイズになります

アクセス関数:

QVector3D scaling() const
void setScaling(QVector3D scaling)

Notifier シグナル:

void scalingChanged(QVector3D scaling)

scalingAbsoluteも参照してください 。

scalingAbsolute : bool

このプロパティは、項目のスケーリングをデータ値で処理するか、絶対値で処理するかを指定します。

デフォルトはtrue です。

絶対スケーリングが適用されたアイテムは、軸の範囲に関係なく、常に同じサイズでレンダリングされます。 データスケーリングが適用された項目は、軸の範囲に応じて見かけのサイズが変化します。positionAbsolute がtrue の場合、このプロパティは無視され、スケーリングは絶対値として解釈されます。項目に回転が設定されている場合、データスケーリングは回転前の項目に基づいて計算されます。同様に、QCustom3DVolume 項目についても、範囲のクリッピングは回転前の項目に基づいて計算されます。

注: QCustom3DLabel アイテム、またはpolar グラフで使用されるカスタムアイテムでは、絶対スケーリングのみが サポートされています。

注:カスタム項目のメッシュは 、範囲[-1 ,1] に正規化する必要があります。そうしないと、データのスケーリングが正確に行われません。

アクセス関数:

bool isScalingAbsolute() const
void setScalingAbsolute(bool scalingAbsolute)

通知信号:

void scalingAbsoluteChanged(bool scalingAbsolute)

「 scaling 」および「positionAbsolute 」も参照してください 。

shadowCasting : bool

このプロパティは、アイテムの影の投影が有効かどうかを指定します。

デフォルトはtrue です。false の場合、Q3DGraphsWidgetItem::ShadowQualityの設定にかかわらず、アイテムは影を落としません。

アクセス関数:

bool isShadowCasting() const
void setShadowCasting(bool enabled)

通知シグナル:

void shadowCastingChanged(bool shadowCasting)

textureFile : QString

このプロパティには、アイテムのテクスチャファイル名が格納されます。

このプロパティとテクスチャ画像の両方が設定されていない場合、一色のグレーのテクスチャが使用されます。

注: メモリを節約するため 、ファイルから読み込まれたQImage は、テクスチャの作成後にクリアされます。

アクセス関数:

QString textureFile() const
void setTextureFile(const QString &textureFile)

通知シグナル:

void textureFileChanged(const QString &textureFile)

visible : bool

このプロパティは、項目の表示設定を保持します。

デフォルト値は `true` です。

アクセス関数:

bool isVisible() const
void setVisible(bool visible)

通知シグナル:

void visibleChanged(bool visible)

メンバ関数のドキュメント

[explicit] QCustom3DItem::QCustom3DItem(QObject *parent = nullptr)

指定されたparent を使用して、カスタム3Dアイテムを作成します。

[explicit] QCustom3DItem::QCustom3DItem(const QString &meshFile, QVector3D position, QVector3D scaling, const QQuaternion &rotation, const QImage &texture, QObject *parent = nullptr)

指定されたmeshFile 、position 、scaling 、rotation 、texture の画像、およびオプションのparent を使用して、カスタム3Dアイテムを作成します。

[override virtual noexcept] QCustom3DItem::~QCustom3DItem()

カスタム3Dアイテムを削除します。

[invokable] void QCustom3DItem::setRotationAxisAndAngle(QVector3D axis, float angle)

axis およびangle から回転クォータニオンを生成するための便利関数です。

注:この関数は 、メタオブジェクトシステムやQMLから呼び出すことができます。Q_INVOKABLE を参照してください。

rotationも参照してください 。

void QCustom3DItem::setTextureImage(const QImage &textureImage)

textureImage の値を、そのアイテムのQImage として設定します。テクスチャはデフォルトで一色の灰色になります。

注: メモリを節約するため 、テクスチャの作成後、指定されたQImage はクリアされます。

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