6.0.0-rc4Source

QAbstractAxis Class

The QAbstractAxis class is the base class of the axes of a chart. More…

Header#include <QAbstractAxis>
CMaketarget_link_libraries(app PRIVATE Nt::Charts)
ModuleNt Charts C++ Classes
InheritsQObject
Inherited byQBarCategoryAxis, QDateTimeAxis, QLogValueAxis, QValueAxis

List of all members, including inherited members

Public Types

enumAxisType
typedefAxisTypes

Public Functions

~QAbstractAxis()
virtual AxisTypetype() const
boolisVisible() const
voidsetVisible(bool visible = true)
voidshow()
voidhide()
boolisLineVisible() const
voidsetLineVisible(bool visible = true)
QPenlinePen() const
voidsetLinePen(const QPen &pen)
QColorlinePenColor() const
voidsetLinePenColor(QColor color)
boolisGridLineVisible() const
voidsetGridLineVisible(bool visible = true)
QPengridLinePen() const
voidsetGridLinePen(const QPen &pen)
QColorgridLineColor() const
voidsetGridLineColor(const QColor &color)
boolisMinorGridLineVisible() const
voidsetMinorGridLineVisible(bool visible = true)
QPenminorGridLinePen() const
voidsetMinorGridLinePen(const QPen &pen)
QColorminorGridLineColor() const
voidsetMinorGridLineColor(const QColor &color)
boollabelsVisible() const
voidsetLabelsVisible(bool visible = true)
QBrushlabelsBrush() const
voidsetLabelsBrush(const QBrush &brush)
QFontlabelsFont() const
voidsetLabelsFont(const QFont &font)
intlabelsAngle() const
voidsetLabelsAngle(int angle)
QColorlabelsColor() const
voidsetLabelsColor(QColor color)
boolisTitleVisible() const
voidsetTitleVisible(bool visible = true)
QBrushtitleBrush() const
voidsetTitleBrush(const QBrush &brush)
QFonttitleFont() const
voidsetTitleFont(const QFont &font)
QStringtitleText() const
voidsetTitleText(const QString &title)
boolshadesVisible() const
voidsetShadesVisible(bool visible = true)
QPenshadesPen() const
voidsetShadesPen(const QPen &pen)
QBrushshadesBrush() const
voidsetShadesBrush(const QBrush &brush)
QColorshadesColor() const
voidsetShadesColor(QColor color)
QColorshadesBorderColor() const
voidsetShadesBorderColor(QColor color)
Qt::Orientationorientation() const
Qt::Alignmentalignment() const
voidsetMin(const QVariant &min)
voidsetMax(const QVariant &max)
voidsetRange(const QVariant &min, const QVariant &max)
boolisReverse() const
voidsetReverse(bool reverse = true)

Signals

voidvisibleChanged(bool visible)
voidlinePenChanged(const QPen &pen)
voidlineVisibleChanged(bool visible)
voidlabelsVisibleChanged(bool visible)
voidlabelsBrushChanged(const QBrush &brush)
voidlabelsFontChanged(const QFont &font)
voidlabelsAngleChanged(int angle)
voidgridLinePenChanged(const QPen &pen)
voidgridVisibleChanged(bool visible)
voidminorGridVisibleChanged(bool visible)
voidminorGridLinePenChanged(const QPen &pen)
voidgridLineColorChanged(const QColor &color)
voidminorGridLineColorChanged(const QColor &color)
voidcolorChanged(QColor color)
voidlabelsColorChanged(QColor color)
voidtitleTextChanged(const QString &title)
voidtitleBrushChanged(const QBrush &brush)
voidtitleVisibleChanged(bool visible)
voidtitleFontChanged(const QFont &font)
voidshadesVisibleChanged(bool visible)
voidshadesColorChanged(QColor color)
voidshadesBorderColorChanged(QColor color)
voidshadesPenChanged(const QPen &pen)
voidshadesBrushChanged(const QBrush &brush)
voidreverseChanged(bool reverse)

Protected Functions

QAbstractAxis(QObject *parent = nullptr)
voidmarkChanged()
virtual voidsetRangeFromVariant(const QVariant &min, const QVariant &max)

Detailed Description

An axis maps the values of the series attached to it to one direction of the plot area, and draws a line, ticks, labels, grid lines and an optional title. Add an axis to a chart with QChart::addAxis(), then attach series to it with QAbstractSeries::attachAxis():

auto *axisY = new QValueAxis;
axisY->setTitleText("Load (%)");
chart->addAxis(axisY, Qt::AlignLeft);
series->attachAxis(axisY);

Colors and fonts that are not set come from the theme of the chart. QChart::setTheme() forgets the ones that were set.

See also QValueAxis, QLogValueAxis, QDateTimeAxis, QBarCategoryAxis and QChart.

Differences from Qt

The axis is a QObject, not a graphics item. Labels are drawn upright: labelsAngle() is kept but not used. There is no QCategoryAxis or QColorAxis, and no truncation of labels or label editing.

Member Type Documentation

enum QAbstractAxis::AxisType

The type of an axis.

ConstantDescription
QAbstractAxis::AxisTypeNoAxisNo axis.
QAbstractAxis::AxisTypeValueA QValueAxis.
QAbstractAxis::AxisTypeBarCategoryA QBarCategoryAxis.
QAbstractAxis::AxisTypeCategoryA category axis with ranges; Nt has none.
QAbstractAxis::AxisTypeDateTimeA QDateTimeAxis.
QAbstractAxis::AxisTypeLogValueA QLogValueAxis.
QAbstractAxis::AxisTypeColorA color scale axis; Nt has none.

typedef QAbstractAxis::AxisTypes

A QFlags of AxisType values.

Member Function Documentation

[explicit, protected] QAbstractAxis::QAbstractAxis(QObject *parent = nullptr)

Constructs an axis with the given parent. The axis does nothing until it is added to a chart.

[override] QAbstractAxis::~QAbstractAxis()

Destroys the axis and removes it from its chart.

Qt::Alignment QAbstractAxis::alignment() const

Returns the side of the plot area the axis is drawn on, or no alignment if it is not in a chart.

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

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

QColor QAbstractAxis::gridLineColor() const

Returns the color of the grid lines.

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

This signal is emitted when the color of the grid lines changes to color.

QPen QAbstractAxis::gridLinePen() const

Returns the pen of the grid lines.

[signal] void QAbstractAxis::gridLinePenChanged(const QPen &pen)

This signal is emitted when the pen of the grid lines changes to pen.

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

This signal is emitted when the grid lines are shown or hidden; visible is the new state.

void QAbstractAxis::hide()

Hides the axis.

bool QAbstractAxis::isGridLineVisible() const

Returns true if grid lines are drawn at the ticks; otherwise returns false.

bool QAbstractAxis::isLineVisible() const

Returns true if the axis line is drawn; otherwise returns false.

bool QAbstractAxis::isMinorGridLineVisible() const

Returns true if minor grid lines are drawn; otherwise returns false. Value and logarithmic axes have them, between the ticks.

bool QAbstractAxis::isReverse() const

Returns true if the axis runs from its maximum to its minimum; otherwise returns false.

bool QAbstractAxis::isTitleVisible() const

Returns true if the title is drawn when it is not empty; otherwise returns false.

bool QAbstractAxis::isVisible() const

Returns true if the axis is drawn; otherwise returns false.

See also setVisible().

int QAbstractAxis::labelsAngle() const

Returns the angle of the labels, in degrees.

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

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

QBrush QAbstractAxis::labelsBrush() const

Returns the brush of the labels. Its color is the color of the text.

[signal] void QAbstractAxis::labelsBrushChanged(const QBrush &brush)

This signal is emitted when the brush of the labels changes to brush.

QColor QAbstractAxis::labelsColor() const

Returns the color of the labels.

[signal] void QAbstractAxis::labelsColorChanged(QColor color)

This signal is emitted when the color of the labels changes to color.

QFont QAbstractAxis::labelsFont() const

Returns the font of the labels.

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

This signal is emitted when the font of the labels changes to font.

bool QAbstractAxis::labelsVisible() const

Returns true if the labels are drawn; otherwise returns false.

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

This signal is emitted when the labels are shown or hidden; visible is the new state.

QPen QAbstractAxis::linePen() const

Returns the pen of the axis line and its ticks.

[signal] void QAbstractAxis::linePenChanged(const QPen &pen)

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

QColor QAbstractAxis::linePenColor() const

Returns the color of the axis line.

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

This signal is emitted when the axis line is shown or hidden; visible is the new state.

[protected] void QAbstractAxis::markChanged()

Tells the chart that the axis must be drawn again.

QColor QAbstractAxis::minorGridLineColor() const

Returns the color of the minor grid lines.

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

This signal is emitted when the color of the minor grid lines changes to color.

QPen QAbstractAxis::minorGridLinePen() const

Returns the pen of the minor grid lines.

[signal] void QAbstractAxis::minorGridLinePenChanged(const QPen &pen)

This signal is emitted when the pen of the minor grid lines changes to pen.

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

This signal is emitted when the minor grid lines are shown or hidden; visible is the new state.

Qt::Orientation QAbstractAxis::orientation() const

Returns the orientation of the axis, which follows from the alignment it was added with: Qt::Horizontal at the top or bottom, Qt::Vertical at the left or right.

[signal] void QAbstractAxis::reverseChanged(bool reverse)

This signal is emitted when the direction of the axis changes; reverse is the new state.

void QAbstractAxis::setGridLineColor(const QColor &color)

Sets the color of the grid lines to color.

void QAbstractAxis::setGridLinePen(const QPen &pen)

Sets the pen of the grid lines to pen.

void QAbstractAxis::setGridLineVisible(bool visible = true)

Shows the grid lines if visible is true and hides them otherwise.

void QAbstractAxis::setLabelsAngle(int angle)

Sets the angle of the labels to angle degrees. Nt keeps the value and draws the labels upright.

void QAbstractAxis::setLabelsBrush(const QBrush &brush)

Sets the brush of the labels to brush.

void QAbstractAxis::setLabelsColor(QColor color)

Sets the color of the labels to color.

void QAbstractAxis::setLabelsFont(const QFont &font)

Sets the font of the labels to font.

void QAbstractAxis::setLabelsVisible(bool visible = true)

Shows the labels if visible is true and hides them otherwise.

void QAbstractAxis::setLinePen(const QPen &pen)

Sets the pen of the axis line and its ticks to pen.

void QAbstractAxis::setLinePenColor(QColor color)

Sets the color of the axis line to color.

void QAbstractAxis::setLineVisible(bool visible = true)

Shows the axis line if visible is true and hides it otherwise.

void QAbstractAxis::setMax(const QVariant &max)

Sets the maximum of the axis to max, converted to the type of the axis.

void QAbstractAxis::setMin(const QVariant &min)

Sets the minimum of the axis to min, converted to the type of the axis.

void QAbstractAxis::setMinorGridLineColor(const QColor &color)

Sets the color of the minor grid lines to color.

void QAbstractAxis::setMinorGridLinePen(const QPen &pen)

Sets the pen of the minor grid lines to pen.

void QAbstractAxis::setMinorGridLineVisible(bool visible = true)

Shows the minor grid lines if visible is true and hides them otherwise.

See also QValueAxis::setMinorTickCount().

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

Sets the range of the axis to min and max, converted to the type of the axis.

[virtual, protected] void QAbstractAxis::setRangeFromVariant(const QVariant &min, const QVariant &max)

Sets the range of the axis to min and max, converted to the type of the axis. setMin(), setMax() and setRange() call it.

void QAbstractAxis::setReverse(bool reverse = true)

Makes the axis run from its maximum to its minimum if reverse is true: right to left, or top to bottom.

void QAbstractAxis::setShadesBorderColor(QColor color)

Sets the border color of the shades to color.

void QAbstractAxis::setShadesBrush(const QBrush &brush)

Sets the brush of the shades to brush.

void QAbstractAxis::setShadesColor(QColor color)

Sets the fill color of the shades to color.

void QAbstractAxis::setShadesPen(const QPen &pen)

Sets the pen of the borders of the shades to pen.

void QAbstractAxis::setShadesVisible(bool visible = true)

Shades every other interval between ticks if visible is true.

void QAbstractAxis::setTitleBrush(const QBrush &brush)

Sets the brush of the title to brush.

void QAbstractAxis::setTitleFont(const QFont &font)

Sets the font of the title to font.

void QAbstractAxis::setTitleText(const QString &title)

Sets the title of the axis to title. A vertical axis draws its title upright, above its labels.

void QAbstractAxis::setTitleVisible(bool visible = true)

Shows the title if visible is true and hides it otherwise.

void QAbstractAxis::setVisible(bool visible = true)

Shows the axis if visible is true and hides it otherwise. A hidden axis still maps its series.

QColor QAbstractAxis::shadesBorderColor() const

Returns the border color of the shades.

[signal] void QAbstractAxis::shadesBorderColorChanged(QColor color)

This signal is emitted when the border color of the shades changes to color.

QBrush QAbstractAxis::shadesBrush() const

Returns the brush of the shades.

[signal] void QAbstractAxis::shadesBrushChanged(const QBrush &brush)

This signal is emitted when the brush of the shades changes to brush.

QColor QAbstractAxis::shadesColor() const

Returns the fill color of the shades.

[signal] void QAbstractAxis::shadesColorChanged(QColor color)

This signal is emitted when the fill color of the shades changes to color.

QPen QAbstractAxis::shadesPen() const

Returns the pen of the borders of the shades.

[signal] void QAbstractAxis::shadesPenChanged(const QPen &pen)

This signal is emitted when the pen of the shades changes to pen.

bool QAbstractAxis::shadesVisible() const

Returns true if every other interval between ticks is shaded; otherwise returns false.

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

This signal is emitted when the shades are shown or hidden; visible is the new state.

void QAbstractAxis::show()

Shows the axis.

QBrush QAbstractAxis::titleBrush() const

Returns the brush of the title.

[signal] void QAbstractAxis::titleBrushChanged(const QBrush &brush)

This signal is emitted when the brush of the title changes to brush.

QFont QAbstractAxis::titleFont() const

Returns the font of the title.

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

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

QString QAbstractAxis::titleText() const

Returns the title of the axis.

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

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

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

This signal is emitted when the title is shown or hidden; visible is the new state.

[virtual] AxisType QAbstractAxis::type() const

Returns the type of the axis.

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

This signal is emitted when the axis is shown or hidden; visible is the new state.