QGraphsTheme Class
QGraphsTheme クラスは、グラフの視覚的なスタイルを提供します。詳細...
| ヘッダー: | #include <QGraphsTheme> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Graphs) target_link_libraries(mytarget PRIVATE Qt6::Graphs) |
| qmake: | QT += graphs |
| QML内: | GraphsTheme |
| 継承元: | QObject およびQQmlParserStatus |
- 継承されたメンバーを含む、すべてのメンバーの一覧
- QGraphsThemeは、Qt Graphs のC++共通クラス群の一部です。
パブリック型
| enum class | ColorScheme { Automatic, Light, Dark } |
| enum class | ColorStyle { Uniform, ObjectGradient, RangeGradient } |
| enum class | Theme { QtGreen, QtGreenNeon, MixSeries, OrangeSeries, YellowSeries, …, UserDefined } |
プロパティ
|
|
パブリック関数
| QGraphsLine | axisX() const |
| QFont | axisXLabelFont() const |
| QGraphsLine | axisY() const |
| QFont | axisYLabelFont() const |
| QGraphsLine | axisZ() const |
| QFont | axisZLabelFont() const |
| QColor | backgroundColor() const |
| QList<QColor> | borderColors() const |
| qreal | borderWidth() const |
| QGraphsTheme::ColorScheme | colorScheme() const |
| QGraphsTheme::ColorStyle | colorStyle() const |
| QGraphsLine | grid() const |
| bool | isBackgroundVisible() const |
| bool | isGridVisible() const |
| bool | isLabelBackgroundVisible() const |
| bool | isLabelBorderVisible() const |
| bool | isPlotAreaBackgroundVisible() const |
| QColor | labelBackgroundColor() const |
| QFont | labelFont() const |
| QColor | labelTextColor() const |
| bool | labelsVisible() const |
| QColor | multiHighlightColor() const |
| QColor | plotAreaBackgroundColor() const |
| QList<QColor> | seriesColors() const |
| QList<QLinearGradient> | seriesGradients() const |
| void | setAxisX(const QGraphsLine &newAxisX) |
| void | setAxisXLabelFont(const QFont &newAxisXLabelFont) |
| void | setAxisY(const QGraphsLine &newAxisY) |
| void | setAxisYLabelFont(const QFont &newAxisYLabelFont) |
| void | setAxisZ(const QGraphsLine &newAxisZ) |
| void | setAxisZLabelFont(const QFont &newAxisZLabelFont) |
| void | setBackgroundColor(QColor newBackgroundColor) |
| void | setBackgroundVisible(bool newBackgroundVisible) |
| void | setBorderColors(const QList<QColor> &newBorderColors) |
| void | setBorderWidth(qreal newBorderWidth) |
| void | setColorScheme(QGraphsTheme::ColorScheme newColorScheme) |
| void | setColorStyle(QGraphsTheme::ColorStyle newColorStyle) |
| void | setGrid(const QGraphsLine &newGrid) |
| void | setGridVisible(bool newGridVisibility) |
| void | setLabelBackgroundColor(QColor newLabelBackgroundColor) |
| void | setLabelBackgroundVisible(bool newLabelBackgroundVisibility) |
| void | setLabelBorderVisible(bool newLabelBorderVisibility) |
| void | setLabelFont(const QFont &newFont) |
| void | setLabelTextColor(QColor newLabelTextColor) |
| void | setLabelsVisible(bool newLabelsVisibility) |
| void | setMultiHighlightColor(QColor newMultiHighlightColor) |
| void | setPlotAreaBackgroundColor(QColor newBackgroundColor) |
| void | setPlotAreaBackgroundVisible(bool newBackgroundVisibility) |
| void | setSeriesColors(const QList<QColor> &newSeriesColors) |
| void | setSeriesGradients(const QList<QLinearGradient> &newSeriesGradients) |
| void | setSingleHighlightColor(QColor newSingleHighlightColor) |
| void | setTheme(QGraphsTheme::Theme newTheme, QGraphsTheme::ForceTheme force = ForceTheme::No) |
| QColor | singleHighlightColor() const |
| QGraphsTheme::Theme | theme() const |
シグナル
| void | axisXChanged() |
| void | axisXLabelFontChanged() |
| void | axisYChanged() |
| void | axisYLabelFontChanged() |
| void | axisZChanged() |
| void | axisZLabelFontChanged() |
| void | backgroundColorChanged() |
| void | backgroundVisibleChanged() |
| void | borderColorsChanged() |
| void | borderWidthChanged() |
| void | colorSchemeChanged() |
| void | colorStyleChanged(QGraphsTheme::ColorStyle type) |
| void | gridChanged() |
| void | gridVisibleChanged() |
| void | labelBackgroundColorChanged() |
| void | labelBackgroundVisibleChanged() |
| void | labelBorderVisibleChanged() |
| void | labelFontChanged() |
| void | labelTextColorChanged() |
| void | labelsVisibleChanged() |
| void | multiHighlightColorChanged(QColor color) |
| void | multiHighlightGradientQMLChanged() |
| void | plotAreaBackgroundColorChanged() |
| void | plotAreaBackgroundVisibleChanged() |
| void | seriesColorsChanged(const QList<QColor> &list) |
| void | singleHighlightColorChanged(QColor color) |
| void | singleHighlightGradientQMLChanged() |
| void | themeChanged(QGraphsTheme::Theme theme) |
詳細な説明
グラフ全体に影響する視覚的なプロパティを指定します。そのまま使用することも、自由に変更することもできる組み込みテーマがいくつか用意されています。
UserDefined 列挙型の値を使用して、テーマをゼロから作成することもできます。デフォルトのコンストラクタを使用してテーマを作成すると、新しいユーザー定義テーマが生成されます。
テーマのカスタマイズ
デフォルトのテーマは `QtGreen` ですが、各プロパティをカスタマイズすることができます。
次の表に、テーマによって制御されるプロパティと、UserDefined のデフォルト値を示します。
| プロパティ | デフォルト値 |
|---|---|
| backgroundVisible | true |
| seriesColors | Qt::black |
| seriesGradients | QLinearGradient. 実質的に全面黒。 |
| colorStyle | Uniform |
| labelFont | QFont |
| gridVisible | true |
| labelBackgroundVisible | true |
| labelBorderVisible | true |
| labelsVisible | true |
使用例
変更を加えずに組み込みテーマを作成する:
QGraphsTheme *theme = new QGraphsTheme();組み込みテーマを作成し、一部のプロパティを変更する:
QGraphsTheme *theme = new QGraphsTheme();
theme->setBackgroundVisible(false);
theme->setLabelBackgroundVisible(false);ユーザー定義テーマの変更。このテーマは、前のスニペットと同じ方法で作成されています:
theme->setTheme(QGraphsTheme::Theme::UserDefined);
theme->setBackgroundColor(QColor(QRgb(0x99ca53)));
theme->setBackgroundVisible(true);
QList<QColor> colors = { QColor(QRgb(0x209fdf)) };
theme->setSeriesColors(colors);
theme->setColorStyle(QGraphsTheme::ColorStyle::Uniform);
theme->setLabelFont(QFont(QStringLiteral("Impact"), 35));
theme->setGridVisible(true);
auto gridline = theme->grid();
gridline.setMainColor(QColor(QRgb(0x99ca53)));
theme->setGrid(gridline);
theme->setLabelBackgroundColor(QColor(0xf6, 0xa6, 0x25, 0xa0));
theme->setLabelBackgroundVisible(true);
theme->setLabelBorderVisible(true);
theme->setLabelTextColor(QColor(QRgb(0x404044)));
theme->setMultiHighlightColor(QColor(QRgb(0x6d5fd5)));
theme->setSingleHighlightColor(QColor(QRgb(0xf6a625)));
theme->setBackgroundColor(QColor(QRgb(0xffffff)));グラフにテーマを設定した後、一部のプロパティを変更する:
QQuickWidget quickWidget;
Q3DBarsWidgetItem bars;
bars.setWidget(&quickWidget);
bars.widget()->setMinimumSize(QSize(512, 512));
bars.activeTheme()->setTheme(QGraphsTheme::Theme::MixSeries);
QList<QColor> color = { QColor(Qt::red) };
bars.activeTheme()->setSeriesColors(color);
bars.activeTheme()->setSingleHighlightColor(Qt::yellow);メンバ型のドキュメント
enum class QGraphsTheme::ColorScheme
グラフの配色を表します。
| 定数 | 値 | 説明 |
|---|---|---|
QGraphsTheme::ColorScheme::Automatic | 0 | 背景色は、利用可能な場合はプラットフォームの配色に従います。利用できない場合は、「ライト」のテーマが使用されます。 |
QGraphsTheme::ColorScheme::Light | 1 | 背景色はテキスト色よりも明るい、つまりテーマは「ライト」です。 |
QGraphsTheme::ColorScheme::Dark | 2 | 背景色はテキスト色よりも暗く、つまりテーマは「ダーク」です。 |
関連項目: Qt::ColorScheme 。
enum class QGraphsTheme::ColorStyle
勾配の種類。
| 一定 | 値 | 説明 |
|---|---|---|
QGraphsTheme::ColorStyle::Uniform | 0 | オブジェクトは単一の色でレンダリングされます。使用される色は、seriesColors 、singleHighlightColor 、およびmultiHighlightColor プロパティで指定されます。 |
QGraphsTheme::ColorStyle::ObjectGradient | 1 | オブジェクトの高さに関係なく、オブジェクトごとに完全なグラデーションを使用して色付けされます。使用されるグラデーションは、seriesGradients 、singleHighlightGradient 、およびmultiHighlightGradient プロパティで指定されます。 |
QGraphsTheme::ColorStyle::RangeGradient | 2 | オブジェクトは、その高さと Y 軸上の位置に基づいて決定されるフルグラデーションの一部を使用して着色されます。使用されるグラデーションは、seriesGradients 、singleHighlightGradient 、およびmultiHighlightGradient プロパティで指定されます。 |
enum class QGraphsTheme::Theme
組み込みテーマ。
| 定数 | 値 | 説明 |
|---|---|---|
QGraphsTheme::Theme::QtGreen | 0 | ベースカラーに緑を使用した明るいテーマ。 |
QGraphsTheme::Theme::QtGreenNeon | 1 | ベースカラーに緑のネオン色を使用した明るいテーマ。 |
QGraphsTheme::Theme::MixSeries | 2 | さまざまな色が混ざったテーマ。 |
QGraphsTheme::Theme::OrangeSeries | 3 | オレンジを基調色としたテーマ。 |
QGraphsTheme::Theme::YellowSeries | 4 | 黄色を基調色としたテーマ。 |
QGraphsTheme::Theme::BlueSeries | 5 | 青を基調色としたテーマ。 |
QGraphsTheme::Theme::PurpleSeries | 6 | 紫を基調色としたテーマ。 |
QGraphsTheme::Theme::GreySeries | 7 | グレーを基調色としたテーマ。 |
QGraphsTheme::Theme::UserDefined | 8 | ユーザー定義のテーマ。詳細については、Customizing Theme を参照してください。 |
プロパティのドキュメント
axisX : QGraphsLine
グラフのX軸の線およびラベルのスタイル設定プロパティ。
アクセス関数:
| QGraphsLine | axisX() const |
| void | setAxisX(const QGraphsLine &newAxisX) |
通知シグナル:
| void | axisXChanged() |
axisXLabelFont : QFont
このプロパティは、X軸のラベルに使用するフォントを指定します。
アクセス関数:
| QFont | axisXLabelFont() const |
| void | setAxisXLabelFont(const QFont &newAxisXLabelFont) |
通知シグナル:
| void | axisXLabelFontChanged() |
axisY : QGraphsLine
グラフのY軸の線およびラベルの書式設定プロパティ。
アクセス関数:
| QGraphsLine | axisY() const |
| void | setAxisY(const QGraphsLine &newAxisY) |
通知信号:
| void | axisYChanged() |
axisYLabelFont : QFont
このプロパティは、Y軸のラベルに使用するフォントを指定します。
アクセス関数:
| QFont | axisYLabelFont() const |
| void | setAxisYLabelFont(const QFont &newAxisYLabelFont) |
通知シグナル:
| void | axisYLabelFontChanged() |
axisZ : QGraphsLine
グラフのZ軸の線およびラベルのスタイル設定プロパティ。
アクセス関数:
| QGraphsLine | axisZ() const |
| void | setAxisZ(const QGraphsLine &newAxisZ) |
通知信号:
| void | axisZChanged() |
axisZLabelFont : QFont
このプロパティは、Z軸のラベルに使用するフォントを指定します。
アクセス関数:
| QFont | axisZLabelFont() const |
| void | setAxisZLabelFont(const QFont &newAxisZLabelFont) |
通知シグナル:
| void | axisZLabelFontChanged() |
backgroundColor : QColor
このプロパティは、グラフが描画されるビューの色を保持します。デフォルト値は、colorScheme によって決まります。
アクセス関数:
| QColor | backgroundColor() const |
| void | setBackgroundColor(QColor newBackgroundColor) |
Notifierシグナル:
| void | backgroundColorChanged() |
backgroundVisible : bool
このプロパティは、背景が表示されるかどうかを指定します。
背景は、backgroundColor の値を使用して描画されます。デフォルト値はtrue です。
アクセス関数:
| bool | isBackgroundVisible() const |
| void | setBackgroundVisible(bool newBackgroundVisible) |
Notifierシグナル:
| void | backgroundVisibleChanged() |
[read-only] baseColors : const QQmlListProperty<QQuickGraphsColor>
「ColorStyle::Uniform 」カラースタイルを使用する場合、このシリーズで用いるベースカラーの一覧。
[read-only] baseGradients : const QQmlListProperty<QQuickGradient>
「ColorStyle::RangeGradient 」カラースタイルを使用する際、このシリーズに適用される基本グラデーションの一覧。
borderColors : QList<QColor>
このプロパティには、グラフ内のすべてのオブジェクトに対して、シリーズごとに使用される枠線の色のリストが格納されます。
色の数よりも系列の数が多い場合、色リストは折り返され、リストの最初の色から再び繰り返されます。
colorStyle がUniformでない場合、このプロパティは即座に効果を発揮しません。
アクセス関数:
| QList<QColor> | borderColors() const |
| void | setBorderColors(const QList<QColor> &newBorderColors) |
通知シグナル:
| void | borderColorsChanged() |
borderWidth : qreal
このプロパティは、グラフに境界線がある場合のその幅を指定します。デフォルト値は `1.0` です。
アクセス関数:
| qreal | borderWidth() const |
| void | setBorderWidth(qreal newBorderWidth) |
通知シグナル:
| void | borderWidthChanged() |
colorScheme : QGraphsTheme::ColorScheme
使用中のグラフの配色。
アクセス関数:
| QGraphsTheme::ColorScheme | colorScheme() const |
| void | setColorScheme(QGraphsTheme::ColorScheme newColorScheme) |
通知信号:
| void | colorSchemeChanged() |
Qt::ColorSchemeも参照してください 。
colorStyle : QGraphsTheme::ColorStyle
グラフの色のスタイル。QGraphsTheme::ColorStyle 列挙型の値のいずれかです。
この値は、シリーズ内でAbstract3DSeries.colorStyle を明示的に設定することで上書きできます。
注:この プロパティは、2DのQt Graphs では効果がありません。
アクセス関数:
| QGraphsTheme::ColorStyle | colorStyle() const |
| void | setColorStyle(QGraphsTheme::ColorStyle newColorStyle) |
通知シグナル:
| void | colorStyleChanged(QGraphsTheme::ColorStyle type) |
関連項目: QGraphsTheme::ColorStyle 。
grid : QGraphsLine
グラフのグリッド線のスタイル設定プロパティ。
アクセス関数:
| QGraphsLine | grid() const |
| void | setGrid(const QGraphsLine &newGrid) |
通知シグナル:
| void | gridChanged() |
gridVisible : bool
このプロパティは、グリッド線が描画されるかどうかを指定します。
この値はすべてのグリッド線に影響します。デフォルト値はtrue です。
アクセス関数:
| bool | isGridVisible() const |
| void | setGridVisible(bool newGridVisibility) |
通知シグナル:
| void | gridVisibleChanged() |
labelBackgroundColor : QColor
このプロパティは、ラベルの背景色を指定します。
labelBackgroundVisible がfalse に設定されている場合は、このプロパティは効果を持ちません。デフォルト値はcolorScheme によって異なります。
アクセス関数:
| QColor | labelBackgroundColor() const |
| void | setLabelBackgroundColor(QColor newLabelBackgroundColor) |
通知シグナル:
| void | labelBackgroundColorChanged() |
labelBackgroundVisible : bool
このプロパティは、ラベルが色付きの背景で描画される場合でも、完全に透明な背景で描画される場合でも有効です。
背景の描画には、labelBackgroundColor の値(アルファ値を含む)が使用されます。
背景を持つラベルは、最も長いラベルを基準に各軸ごとに同じサイズで描画され、テキストはその中央に配置されます。背景を持たないラベルはそのまま描画され、グラフ内での位置に基づいて左揃えまたは右揃えになります。デフォルト値は `true` です。
アクセス関数:
| bool | isLabelBackgroundVisible() const |
| void | setLabelBackgroundVisible(bool newLabelBackgroundVisibility) |
通知シグナル:
| void | labelBackgroundVisibleChanged() |
labelBorderVisible : bool
このプロパティは、背景色を持つラベルに対してラベルの枠線が描画されるかどうかを指定します。
labelBackgroundVisible がfalse に設定されている場合は、このプロパティは効果を持ちません。デフォルト値はtrue です。
アクセス関数:
| bool | isLabelBorderVisible() const |
| void | setLabelBorderVisible(bool newLabelBorderVisibility) |
通知シグナル:
| void | labelBorderVisibleChanged() |
labelFont : QFont
このプロパティには、ラベルに使用するフォントが格納されます。
アクセス関数:
| QFont | labelFont() const |
| void | setLabelFont(const QFont &newFont) |
通知シグナル:
| void | labelFontChanged() |
labelTextColor : QColor
このプロパティは、ラベルに使用されるフォントの色を指定します。
軸に対してlabelTextColor が明示的に指定されている場合、このプロパティは効果を持ちません。
デフォルト値は、colorScheme によって決まります。
アクセス関数:
| QColor | labelTextColor() const |
| void | setLabelTextColor(QColor newLabelTextColor) |
通知シグナル:
| void | labelTextColorChanged() |
labelsVisible : bool
このプロパティは、ラベルが描画されるかどうかを決定します。
これがfalse の場合、他のすべてのラベルのプロパティは効果を持ちません。デフォルト値はtrue です。
アクセス関数:
| bool | labelsVisible() const |
| void | setLabelsVisible(bool newLabelsVisibility) |
通知シグナル:
| void | labelsVisibleChanged() |
multiHighlightColor : QColor
このプロパティは、選択されたオブジェクトのハイライト色を保持します。
selectionMode に「QtGraphs3D::SelectionFlag::Row 」または「QtGraphs3D::SelectionFlag::Column 」フラグが設定されている場合に使用されます。デフォルト値はcolorScheme によって異なります。
アクセス関数:
| QColor | multiHighlightColor() const |
| void | setMultiHighlightColor(QColor newMultiHighlightColor) |
通知シグナル:
| void | multiHighlightColorChanged(QColor color) |
multiHighlightGradient : QQuickGradient*
このプロパティは、選択されたオブジェクトのハイライトのグラデーションを保持します。
selectionMode にQtGraphs3D::SelectionFlag::Row またはQtGraphs3D::SelectionFlag::Column フラグが設定されている場合に使用されます。デフォルト値はcolorScheme によって異なります。
通知シグナル:
| void | multiHighlightGradientQMLChanged() |
plotAreaBackgroundColor : QColor
このプロパティは、グラフのプロット領域の背景色を指定します。デフォルト値は、colorScheme の設定によって異なります。
アクセス関数:
| QColor | plotAreaBackgroundColor() const |
| void | setPlotAreaBackgroundColor(QColor newBackgroundColor) |
通知シグナル:
| void | plotAreaBackgroundColorChanged() |
plotAreaBackgroundVisible : bool
このプロパティは、プロット領域の背景が表示されるかどうかを指定します。
背景は、plotAreaBackgroundColor の値を使用して描画されます。デフォルト値はtrue です。
アクセス関数:
| bool | isPlotAreaBackgroundVisible() const |
| void | setPlotAreaBackgroundVisible(bool newBackgroundVisibility) |
通知シグナル:
| void | plotAreaBackgroundVisibleChanged() |
seriesColors : QList<QColor>
このプロパティには、グラフ内のすべてのオブジェクトに対して、シリーズごとに使用される基本色のリストが格納されます。
色の数よりも系列の数が多い場合、色リストはループし、リストの最初の色から再び繰り返されます。
colorStyle が Uniform でない場合、このプロパティは即座には効果を発揮しません。
この値は、シリーズ内でbaseColor を明示的に設定することで上書きできます。
アクセス関数:
| QList<QColor> | seriesColors() const |
| void | setSeriesColors(const QList<QColor> &newSeriesColors) |
通知シグナル:
| void | seriesColorsChanged(const QList<QColor> &list) |
singleHighlightColor : QColor
このプロパティは、選択されたオブジェクトのハイライト色を保持します。
selectionMode にQtGraphs3D::SelectionFlag::Item フラグが設定されている場合に使用されます。デフォルト値はcolorScheme によって異なります。
アクセス関数:
| QColor | singleHighlightColor() const |
| void | setSingleHighlightColor(QColor newSingleHighlightColor) |
通知シグナル:
| void | singleHighlightColorChanged(QColor color) |
singleHighlightGradient : QQuickGradient*
このプロパティは、選択されたオブジェクトのハイライトのグラデーションを保持します。
selectionMode にQtGraphs3D::SelectionFlag::Item フラグが設定されている場合に使用されます。デフォルト値はcolorScheme によって異なります。
通知シグナル:
| void | singleHighlightGradientQMLChanged() |
theme : QGraphsTheme::Theme
テーマのタイプ。タイプが設定されていない場合、タイプは `GraphsTheme.Theme.QtGreen` となります。アイテムの構築後にテーマのタイプを変更すると、テーマの他のすべてのプロパティが、事前定義されたテーマで指定されている値に変更されます。グラフのアクティブなテーマのタイプを変更すると、関連付けられているすべての系列もリセットされ、新しいテーマが適用されます。
アクセス関数:
| QGraphsTheme::Theme | theme() const |
| void | setTheme(QGraphsTheme::Theme newTheme, QGraphsTheme::ForceTheme force = ForceTheme::No) |
通知シグナル:
| void | themeChanged(QGraphsTheme::Theme theme) |
[read-only] themeChildren : const QQmlListProperty<QObject>
テーマの子オブジェクトの一覧です。これはデフォルトのプロパティであり、QMLのTheme要素内で、childrenというプロパティ名を明示的に使用することなく、子オブジェクトを指定できるようにするものです。
メンバ関数のドキュメント
QList<QLinearGradient> QGraphsTheme::seriesGradients() const
テーマで使用されているシリーズグラデーションのリストを返します。
setSeriesGradients()も参照してください 。
void QGraphsTheme::setSeriesGradients(const QList<QLinearGradient> &newSeriesGradients)
テーマのシリーズグラデーションとして「newSeriesGradients 」を設定します。
seriesGradients()も参照してください 。
© 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.