QAbstractAxis Class

The QAbstractAxis class is a base class used for specialized axis classes. More...

Header: #include <QAbstractAxis>
CMake: find_package(Qt6 REQUIRED COMPONENTS Graphs)
target_link_libraries(mytarget PRIVATE Qt6::Graphs)
qmake: QT += graphs
Instantiated By: AbstractAxis
Inherits: QObject
Inherited By:

QBarCategoryAxis and QValueAxis

Status: Technical Preview

Public Types

enum AxisType { AxisTypeNoAxis, AxisTypeValue, AxisTypeBarCategory }
flags AxisTypes

Properties

Public Functions

virtual ~QAbstractAxis()
Qt::Alignment alignment() const
void hide()
bool isGridLineVisible() const
bool isLineVisible() const
bool isMinorGridLineVisible() const
bool isTitleVisible() const
bool isVisible() const
qreal labelsAngle() const
bool labelsVisible() const
Qt::Orientation orientation() const
void setGridLineVisible(bool visible = true)
void setLabelsAngle(qreal angle)
void setLabelsVisible(bool visible = true)
void setLineVisible(bool visible = true)
void setMax(const QVariant &max)
void setMin(const QVariant &min)
void setMinorGridLineVisible(bool visible = true)
void setRange(const QVariant &min, const QVariant &max)
void setTitleColor(const QColor &color)
void setTitleFont(const QFont &font)
void setTitleText(const QString &title)
void setTitleVisible(bool visible = true)
void setVisible(bool visible = true)
void show()
QColor titleColor() const
QFont titleFont() const
QString titleText() const
virtual QAbstractAxis::AxisType type() const = 0

Signals

void gridVisibleChanged(bool visible)
void labelsAngleChanged(qreal angle)
void labelsVisibleChanged(bool visible)
void lineVisibleChanged(bool visible)
void minorGridVisibleChanged(bool visible)
void titleColorChanged(const QColor &color)
void titleFontChanged(const QFont &font)
void titleTextChanged(const QString &text)
void titleVisibleChanged(bool visible)
void update()
void visibleChanged(bool visible)

Detailed Description

Each series can be bound to only one horizontal and vertical axis.

The properties and visibility of various axis elements, such as axis line, title, labels, and grid lines, can be individually controlled.

Member Type Documentation

enum QAbstractAxis::AxisType
flags QAbstractAxis::AxisTypes

This enum type specifies the type of the axis object.

ConstantValue
QAbstractAxis::AxisTypeNoAxis0x0
QAbstractAxis::AxisTypeValue0x1
QAbstractAxis::AxisTypeBarCategory0x2

The AxisTypes type is a typedef for QFlags<AxisType>. It stores an OR combination of AxisType values.

Property Documentation

[read-only] alignment : const Qt::Alignment

This property holds the alignment of the axis.

Can be Qt::AlignLeft, Qt::AlignRight, Qt::AlignBottom, or Qt::AlignTop.

Access functions:

Qt::Alignment alignment() const

gridVisible : bool

This property holds the visibility of the grid lines. By default, the value is true.

Access functions:

bool isGridLineVisible() const
void setGridLineVisible(bool visible = true)

Notifier signal:

void gridVisibleChanged(bool visible)

labelsAngle : qreal

This property holds the angle of the axis labels in degrees.

Access functions:

qreal labelsAngle() const
void setLabelsAngle(qreal angle)

Notifier signal:

void labelsAngleChanged(qreal angle)

labelsVisible : bool

This property holds whether axis labels are visible. By default, the value is true.

Access functions:

bool labelsVisible() const
void setLabelsVisible(bool visible = true)

Notifier signal:

void labelsVisibleChanged(bool visible)

lineVisible : bool

This property holds the visibility of the axis line. By default, the value is true.

Access functions:

bool isLineVisible() const
void setLineVisible(bool visible = true)

Notifier signal:

void lineVisibleChanged(bool visible)

minorGridVisible : bool

This property holds the visibility of the minor grid lines.

Applies only to axes that support minor grid lines. By default, the value is true.

Access functions:

bool isMinorGridLineVisible() const
void setMinorGridLineVisible(bool visible = true)

Notifier signal:

void minorGridVisibleChanged(bool visible)

[read-only] orientation : const Qt::Orientation

This property holds the orientation of the axis.

Fixed to either Qt::Horizontal or Qt::Vertical when the axis is added to a graph.

Access functions:

Qt::Orientation orientation() const

titleColor : QColor

This property holds the color used to draw the title text.

Access functions:

QColor titleColor() const
void setTitleColor(const QColor &color)

Notifier signal:

void titleColorChanged(const QColor &color)

titleFont : QFont

This property holds the font of the title of the axis.

Access functions:

QFont titleFont() const
void setTitleFont(const QFont &font)

Notifier signal:

void titleFontChanged(const QFont &font)

titleText : QString

This property holds the title of the axis.

Empty by default. Axis titles support HTML formatting.

Access functions:

QString titleText() const
void setTitleText(const QString &title)

Notifier signal:

void titleTextChanged(const QString &text)

titleVisible : bool

This property holds the visibility of the axis title.

By default, the value is true.

Access functions:

bool isTitleVisible() const
void setTitleVisible(bool visible = true)

Notifier signal:

void titleVisibleChanged(bool visible)

visible : bool

This property holds the visibility of the axis. By default, the value is true.

Access functions:

bool isVisible() const
void setVisible(bool visible = true)

Notifier signal:

void visibleChanged(bool visible)

Member Function Documentation

[virtual noexcept] QAbstractAxis::~QAbstractAxis()

Destructs the axis object. When the axis is added to a graph, the graph object takes ownership.

[signal] void QAbstractAxis::gridVisibleChanged(bool visible)

This signal is emitted when the visibility of the grid lines of the axis changes to visible.

Note: Notifier signal for property gridVisible.

void QAbstractAxis::hide()

Makes the axis, labels, and grid lines invisible.

[signal] void QAbstractAxis::labelsAngleChanged(qreal angle)

This signal is emitted when the angle of the axis labels changes to angle.

Note: Notifier signal for property labelsAngle.

[signal] void QAbstractAxis::labelsVisibleChanged(bool visible)

This signal is emitted when the visibility of the labels of the axis changes to visible.

Note: Notifier signal for property labelsVisible.

[signal] void QAbstractAxis::lineVisibleChanged(bool visible)

This signal is emitted when the visibility of the axis line changes to visible.

Note: Notifier signal for property lineVisible.

[signal] void QAbstractAxis::minorGridVisibleChanged(bool visible)

This signal is emitted when the visibility of the minor grid lines of the axis changes to visible.

Note: Notifier signal for property minorGridVisible.

Qt::Orientation QAbstractAxis::orientation() const

Returns the orientation of the axis (vertical or horizontal).

Note: Getter function for property orientation.

void QAbstractAxis::setLineVisible(bool visible = true)

Determines whether the axis line and tick marks are visible.

Note: Setter function for property lineVisible.

See also isLineVisible().

void QAbstractAxis::setMax(const QVariant &max)

Sets the maximum value shown on the axis. Depending on the actual axis type, the max parameter is converted to the appropriate type of value. If the conversion is impossible, the function call does nothing.

void QAbstractAxis::setMin(const QVariant &min)

Sets the minimum value shown on the axis. Depending on the actual axis type, the min parameter is converted to the appropriate type of value. If the conversion is impossible, the function call does nothing.

void QAbstractAxis::setRange(const QVariant &min, const QVariant &max)

Sets the range shown on the axis. Depending on the actual axis type, the min and max parameters are converted to appropriate types of values. If the conversion is impossible, the function call does nothing.

void QAbstractAxis::setTitleColor(const QColor &color)

Sets the color used to draw titles to color.

Note: Setter function for property titleColor.

See also titleColor().

void QAbstractAxis::setTitleFont(const QFont &font)

Sets the font used to draw titles to font.

Note: Setter function for property titleFont.

See also titleFont().

void QAbstractAxis::setVisible(bool visible = true)

Sets the visibility of the axis, labels, and grid lines to visible.

Note: Setter function for property visible.

See also isVisible().

void QAbstractAxis::show()

Makes the axis, labels, and grid lines visible.

QColor QAbstractAxis::titleColor() const

Returns the color used to draw titles.

Note: Getter function for property titleColor.

See also setTitleColor().

[signal] void QAbstractAxis::titleColorChanged(const QColor &color)

This signal is emitted when the color used to draw the axis title changes to color.

Note: Notifier signal for property titleColor.

QFont QAbstractAxis::titleFont() const

Returns the font used to draw titles.

Note: Getter function for property titleFont.

See also setTitleFont().

[signal] void QAbstractAxis::titleFontChanged(const QFont &font)

This signal is emitted when the font of the axis title changes to font.

Note: Notifier signal for property titleFont.

[signal] void QAbstractAxis::titleTextChanged(const QString &text)

This signal is emitted when the text of the axis title changes to text.

Note: Notifier signal for property titleText.

[signal] void QAbstractAxis::titleVisibleChanged(bool visible)

This signal is emitted when the visibility of the title text of the axis changes to visible.

Note: Notifier signal for property titleVisible.

[pure virtual] QAbstractAxis::AxisType QAbstractAxis::type() const

Returns the type of the axis.

[signal] void QAbstractAxis::update()

This signal is emitted when the axis needs to be updated.

[signal] void QAbstractAxis::visibleChanged(bool visible)

This signal is emitted when the visibility of the axis changes to visible.

Note: Notifier signal for property visible.