このページでは

QCategoryAxis Class

QCategoryAxis クラスは、軸上に名前付き範囲を配置します。詳細...

Header: #include <QCategoryAxis>
In QML: CategoryAxis
Inherits: QValueAxis
Status: Deprecated

このクラスは非推奨です。新しいコードでの使用は強くお勧めしません。

パブリック型

enum AxisLabelsPosition { AxisLabelsPositionCenter, AxisLabelsPositionOnValue }

プロパティ

パブリック関数

QCategoryAxis(QObject *parent = nullptr)
virtual ~QCategoryAxis()
void append(const QString &categoryLabel, qreal categoryEndValue)
QStringList categoriesLabels()
int count() const
qreal endValue(const QString &categoryLabel) const
QCategoryAxis::AxisLabelsPosition labelsPosition() const
void remove(const QString &categoryLabel)
void replaceLabel(const QString &oldLabel, const QString &newLabel)
void setLabelsPosition(QCategoryAxis::AxisLabelsPosition position)
void setStartValue(qreal min)
qreal startValue(const QString &categoryLabel = QString()) const

再実装されたパブリック関数

virtual QAbstractAxis::AxisType type() const override

シグナル

void categoriesChanged()
void labelsPositionChanged(QCategoryAxis::AxisLabelsPosition position)

詳細な説明

このクラスは、ラベル付きのカテゴリを追加することで、基礎となるデータを説明するために使用できます。QBarCategoryAxis とは異なり、QCategoryAxisではカテゴリ範囲の幅を自由に指定することができます。

QCategoryAxis の使用方法に関するサンプルコード:

Y軸が「第1」、「第2」、「第3」に分類されている様子を示すスクリーンショットの切り抜き

QChartView *chartView = new QChartView;
QLineSeries *series = new QLineSeries;
// ...
chartView->chart()->addSeries(series);

QCategoryAxis *axisY = new QCategoryAxis;
axisY->setMin(0);
axisY->setMax(52);
axisY->setStartValue(15);
axisY->append("First", 20);
axisY->append("Second", 37);
axisY->append("Third", 52);
chartView->chart()->setAxisY(axisY, series);

メンバ型のドキュメント

enum QCategoryAxis::AxisLabelsPosition

この列挙型は、カテゴリラベルの位置を表します。

定数値説明
QCategoryAxis::AxisLabelsPositionCenter0x0ラベルはカテゴリの中央に配置されます。
QCategoryAxis::AxisLabelsPositionOnValue0x1ラベルはカテゴリの上端に配置されます。

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

[read-only] categoriesLabels : QStringList

このプロパティは、カテゴリラベルを文字列のリストとして保持します。

アクセス関数:

QStringList categoriesLabels()

[read-only] count : int

このプロパティは、カテゴリの数を保持します。

アクセス関数:

int count() const

labelsPosition : AxisLabelsPosition

このプロパティは、カテゴリラベルの位置を指定します。軸の始点および終点にあるラベルは、「値」に基づいて配置された場合、他の軸のラベルと重なることがあります。

アクセス関数:

QCategoryAxis::AxisLabelsPosition labelsPosition() const
void setLabelsPosition(QCategoryAxis::AxisLabelsPosition position)

通知シグナル:

void labelsPositionChanged(QCategoryAxis::AxisLabelsPosition position)

startValue : qreal

このプロパティは、軸上の最初のカテゴリの最小値を保持します。

アクセス関数:

qreal startValue(const QString &categoryLabel = QString()) const
void setStartValue(qreal min)

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

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

parent の子となる軸オブジェクトを作成します。

[virtual noexcept] QCategoryAxis::~QCategoryAxis()

そのオブジェクトを破棄します。

void QCategoryAxis::append(const QString &categoryLabel, qreal categoryEndValue)

ラベルが「categoryLabel 」の新しいカテゴリを軸に追加します。カテゴリラベルは一意である必要があります。categoryEndValue は、そのカテゴリの上限値を指定します。この値は、直前のカテゴリの上限値よりも大きくなければなりません。そうでない場合、このメソッドは新しいカテゴリを追加せずに終了します。

[signal] void QCategoryAxis::categoriesChanged()

この信号は、軸のカテゴリが変更されたときに送信されます。

QStringList QCategoryAxis::categoriesLabels()

カテゴリのラベルのリストを返します。

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

int QCategoryAxis::count() const

カテゴリの数を返します。

注: プロパティ「count」のゲッター 関数です。

qreal QCategoryAxis::endValue(const QString &categoryLabel) const

categoryLabel で指定されたカテゴリの上限値を返します。

void QCategoryAxis::remove(const QString &categoryLabel)

ラベル「categoryLabel 」で指定されたカテゴリを軸から削除します。

void QCategoryAxis::replaceLabel(const QString &oldLabel, const QString &newLabel)

oldLabel で指定された既存のカテゴリラベルを、newLabel に置き換えます。古いラベルが存在しない場合、このメソッドは変更を行わずに戻ります。

void QCategoryAxis::setStartValue(qreal min)

min を、軸上の最初のカテゴリの下限値として設定します。軸にすでにカテゴリが追加されている場合、渡された値は、すでに定義されている最初のカテゴリ範囲の上限値よりも小さくなければなりません。そうでない場合は、何も行われません。

注: プロパティ `startValue`のセッター 関数です。

関連項目 :startValue()

qreal QCategoryAxis::startValue(const QString &categoryLabel = QString()) const

categoryLabel で指定されたカテゴリの下限値を返します。

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

関連項目: setStartValue()。

[override virtual] QAbstractAxis::AxisType QCategoryAxis::type() const

再実装:QValueAxis::type() 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.