QLegend Class

QLegend クラスは、チャートの凡例を表示します。詳細...

Header: #include <QLegend>
In QML: Legend
Inherits: QGraphicsWidget

パブリックな型

enum MarkerShape { MarkerShapeDefault, MarkerShapeRectangle, MarkerShapeCircle, MarkerShapeRotatedRectangle, MarkerShapeTriangle, …, MarkerShapeFromSeries }

プロパティ

パブリック機能

virtual ~QLegend()
Qt::Alignment alignment() const
void attachToChart()
QColor borderColor()
QBrush brush() const
QColor color()
void detachFromChart()
QFont font() const
bool isAttachedToChart()
bool isBackgroundVisible() const
(since 6.2) bool isInteractive() const
QBrush labelBrush() const
QColor labelColor() const
QLegend::MarkerShape markerShape() const
QList<QLegendMarker *> markers(QAbstractSeries *series = nullptr) const
QPen pen() const
bool reverseMarkers()
void setAlignment(Qt::Alignment alignment)
void setBackgroundVisible(bool visible = true)
void setBorderColor(QColor color)
void setBrush(const QBrush &brush)
void setColor(QColor color)
void setFont(const QFont &font)
(since 6.2) void setInteractive(bool interactive)
void setLabelBrush(const QBrush &brush)
void setLabelColor(QColor color)
void setMarkerShape(QLegend::MarkerShape shape)
void setPen(const QPen &pen)
void setReverseMarkers(bool reverseMarkers = true)
void setShowToolTips(bool show)
bool showToolTips() const

シグナル

(since 6.2) void attachedToChartChanged(bool attached)
void backgroundVisibleChanged(bool visible)
void borderColorChanged(QColor color)
void colorChanged(QColor color)
void fontChanged(QFont font)
void labelColorChanged(QColor color)
void markerShapeChanged(QLegend::MarkerShape shape)
void reverseMarkersChanged(bool reverseMarkers)
void showToolTipsChanged(bool showToolTips)

詳細説明

凡例はチャートの凡例を表示するグラフィカル・オブジェクトである。凡例の状態は、系列が変更されるとQChart によって更新される。デフォルトでは、凡例はチャートにアタッチされていますが、チャートのレイアウトから独立させるために切り離すこともできます。凡例オブジェクトは作成も削除もできませんが、QChart クラスを介して参照することができます。

QChartも参照のこと

メンバ型ドキュメント

enum QLegend::MarkerShape

この列挙型は、凡例マーカー項目をレンダリングする際に使用される形状を記述する。

定数説明
QLegend::MarkerShapeDefault0QLegend によって決定されるデフォルトの形状がマーカーに使用される。この値は、個々のQLegendMarker アイテムでのみサポートされます。
QLegend::MarkerShapeRectangle1長方形のマーカーが使用されます。マーカー・サイズはフォント・サイズによって決まります。
QLegend::MarkerShapeCircle2円形マーカーが使用されます。マーカーのサイズはフォントサイズによって決まります。
QLegend::MarkerShapeRotatedRectangle4回転した長方形のマーカーが使用されます。マーカーのサイズはフォントサイズによって決まります。
QLegend::MarkerShapeTriangle5三角形のマーカーを使用します。マーカーのサイズはフォントサイズによって決まります。
QLegend::MarkerShapeStar6星形マーカーを使用します。マーカーサイズはフォントサイズによって決まります。
QLegend::MarkerShapePentagon7五角形のマーカーを使用します。マーカーの大きさはフォントの大きさで決まります。
QLegend::MarkerShapeFromSeries3マーカーの形状は系列によって決まる。散布図系列の場合、凡例マーカーは散布図のドットのように見え、ドットと同じ大きさである。線分またはスプライン系列の場合、凡例マーカは線の小さなセグメントのように見える。その他の系列の場合は、長方形のマーカーが表示される。系列にlightMarker が指定されている場合、lightMarker が表示され、そのサイズは系列のマーカサイズによって決定される。

markerShapeも参照のこと

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

alignment : Qt::Alignment

凡例とチャートの位置関係。

Qt::AlignTop,Qt::AlignBottom,Qt::AlignLeft,Qt::AlignRight のいずれか。複数のフラグを設定した場合、結果は未定義になります。

アクセス関数:

Qt::Alignment alignment() const
void setAlignment(Qt::Alignment alignment)

backgroundVisible : bool

このプロパティは、凡例の背景が表示されているかどうかを保持する。

アクセス関数

bool isBackgroundVisible() const
void setBackgroundVisible(bool visible = true)

通知シグナル

void backgroundVisibleChanged(bool visible)

borderColor : QColor

このプロパティは、凡例の線の色を保持する。

アクセス関数

QColor borderColor()
void setBorderColor(QColor color)

通知シグナル

void borderColorChanged(QColor color)

color : QColor

このプロパティは凡例の背景(ブラシ)色を保持する。

凡例の色を変更すると、凡例のブラシのスタイルはQt::SolidPattern に設定されます。

アクセス関数:

QColor color()
void setColor(QColor color)

通知シグナル:

void colorChanged(QColor color)

font : QFont

このプロパティは、凡例で使用されるマーカーのフォントを保持する。

アクセス関数:

QFont font() const
void setFont(const QFont &font)

通知シグナル

void fontChanged(QFont font)

labelColor : QColor

このプロパティは、ラベルの描画に使用されるブラシの色を保持する。

アクセス関数

QColor labelColor() const
void setLabelColor(QColor color)

通知シグナル

void labelColorChanged(QColor color)

markerShape : MarkerShape

凡例マーカのデフォルト形状。デフォルト値はMarkerShapeRectangle

アクセス関数:

QLegend::MarkerShape markerShape() const
void setMarkerShape(QLegend::MarkerShape shape)

通知シグナル:

void markerShapeChanged(QLegend::MarkerShape shape)

reverseMarkers : bool

このプロパティは、凡例内のマーカーに逆順が使用されるかどうかを保持する。

このプロパティのデフォルトはfalse です。

アクセス関数

bool reverseMarkers()
void setReverseMarkers(bool reverseMarkers = true)

通知シグナル:

void reverseMarkersChanged(bool reverseMarkers)

showToolTips : bool

このプロパティは、テキストが切り詰められたときにツールチップを表示するかどうかを保持する。

このプロパティはデフォルトでfalse

アクセス関数

bool showToolTips() const
void setShowToolTips(bool show)

Notifier シグナル:

void showToolTipsChanged(bool showToolTips)

メンバ関数ドキュメント

[virtual noexcept] QLegend::~QLegend()

凡例オブジェクトを破棄する。凡例は常にQChart によって所有されるので、アプリケーションは決してこの関数を呼び出すべきではない。

void QLegend::attachToChart()

凡例をチャートに取り付ける。チャートは凡例のレイアウトを調整することができる。

[signal, since 6.2] void QLegend::attachedToChartChanged(bool attached)

このシグナルは、凡例がチャートにattached されたとき、またはチャートから切り離されたときに発せられます。

この関数は Qt 6.2 で導入されました。

[signal] void QLegend::backgroundVisibleChanged(bool visible)

このシグナルは、凡例の背景の可視性がvisible に変更されたときに発せられる。

注: プロパティbackgroundVisible に対するノーティファイアシグナル。

[signal] void QLegend::borderColorChanged(QColor color)

このシグナルは、凡例の背景のボーダーカラーがcolor に変更されたときに発行されます。

注: プロパティborderColor に対するノーティファイアシグナル。

QBrush QLegend::brush() const

凡例で使われているブラシを返します。

setBrush()も参照

[signal] void QLegend::colorChanged(QColor color)

このシグナルは、凡例の背景色がcolor に変更されたときに発せられる。

注: プロパティcolor に対するノーティファイアシグナル。

void QLegend::detachFromChart()

チャートから凡例を切り離します。チャートは凡例のレイアウトを調整しなくなります。

[signal] void QLegend::fontChanged(QFont font)

このシグナルは、凡例のマーカーのフォントがfont に変更されたときに発行される。

注: プロパティfont に対するノーティファイアシグナル。

bool QLegend::isAttachedToChart()

凡例がチャートに添付されている場合はtrue を返す。

bool QLegend::isBackgroundVisible() const

凡例の背景の可視性を返す。

注意: プロパティbackgroundVisible のゲッター関数です。

[since 6.2] bool QLegend::isInteractive() const

凡例が切り離されているときに、マウスを使ってドラッグしたりサイズを変更したりできるかどうかを返します。

この関数は Qt 6.2 で導入されました。

QLegend::setInteractive()も参照してください

QBrush QLegend::labelBrush() const

ラベルの描画に使用したブラシを返します。

setLabelBrush()も参照してください

[signal] void QLegend::labelColorChanged(QColor color)

このシグナルは、凡例ラベルの描画に使用されるブラシの色がcolor に変更されたときに発行されます。

注: プロパティlabelColor に対するノーティファイアシグナル。

QList<QLegendMarker *> QLegend::markers(QAbstractSeries *series = nullptr) const

凡例内のマーカーのリストを返す。マーカーを返すseries を指定することで、リストをフィルタリングすることができます。

QPen QLegend::pen() const

凡例が使用しているペンを返します。

setPen()も参照

[signal] void QLegend::reverseMarkersChanged(bool reverseMarkers)

このシグナルは、凡例内のマーカーの逆順の使用がreverseMarkers に変更されたときに発せられる。

注: reverseMarkers プロパティに対するノーティファイアシグナル。

void QLegend::setBackgroundVisible(bool visible = true)

凡例の背景の可視性をvisible に設定します。

注: プロパティbackgroundVisible に対するセッター関数。

isBackgroundVisible()も参照

void QLegend::setBrush(const QBrush &brush)

凡例の背景の描画に使用するbrush を設定します。

brush()も参照

[since 6.2] void QLegend::setInteractive(bool interactive)

interactivetrue で、凡例が切り離されている場合、凡例はウィンドウと同じようにマウスで移動やサイズ変更ができる。

凡例は、チャートの端からドラッグすることで自動的にその端にくっつく。くっついている凡例をダブルクリックすると、凡例が切り離される。これはデフォルトではfalse です。

この関数は Qt 6.2 で導入されました。

QLegend::isInteractive()も参照してください

void QLegend::setLabelBrush(const QBrush &brush)

凡例ラベルの描画に使用するブラシをbrush に設定します。

labelBrush()も参照

void QLegend::setPen(const QPen &pen)

凡例の境界線を描画するために使われるpen を設定します。

pen()も参照

void QLegend::setShowToolTips(bool show)

showtrue の場合、凡例ラベルは、ラベル自体が非表示になっている場合、マウスをその上に置くとツールチップが表示される。これはデフォルトではfalse

注: プロパティshowToolTips に対するセッター関数。

showToolTips()も参照してください

bool QLegend::showToolTips() const

凡例ラベルが消去されたときにツールチップを表示するかどうかを返す。

注: プロパティ showToolTips のゲッター関数。

setShowToolTips()も参照してください

[signal] void QLegend::showToolTipsChanged(bool showToolTips)

このシグナルは、ツールチップの可視性がshowToolTips に変更されたときに発行される。

注: プロパティshowToolTips に対するノーティファイアシグナル。

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