QAbstractAxis Class
The QAbstractAxis class is the base class of the axes of a chart. More…
| Header | #include <QAbstractAxis> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Charts) |
| Module | Nt Charts C++ Classes |
| Inherits | QObject |
| Inherited by | QBarCategoryAxis, QDateTimeAxis, QLogValueAxis, QValueAxis |
List of all members, including inherited members
Public Types
Public Functions
Signals
| void | visibleChanged(bool visible) |
| void | linePenChanged(const QPen &pen) |
| void | lineVisibleChanged(bool visible) |
| void | labelsVisibleChanged(bool visible) |
| void | labelsBrushChanged(const QBrush &brush) |
| void | labelsFontChanged(const QFont &font) |
| void | labelsAngleChanged(int angle) |
| void | gridLinePenChanged(const QPen &pen) |
| void | gridVisibleChanged(bool visible) |
| void | minorGridVisibleChanged(bool visible) |
| void | minorGridLinePenChanged(const QPen &pen) |
| void | gridLineColorChanged(const QColor &color) |
| void | minorGridLineColorChanged(const QColor &color) |
| void | colorChanged(QColor color) |
| void | labelsColorChanged(QColor color) |
| void | titleTextChanged(const QString &title) |
| void | titleBrushChanged(const QBrush &brush) |
| void | titleVisibleChanged(bool visible) |
| void | titleFontChanged(const QFont &font) |
| void | shadesVisibleChanged(bool visible) |
| void | shadesColorChanged(QColor color) |
| void | shadesBorderColorChanged(QColor color) |
| void | shadesPenChanged(const QPen &pen) |
| void | shadesBrushChanged(const QBrush &brush) |
| void | reverseChanged(bool reverse) |
Protected Functions
| QAbstractAxis(QObject *parent = nullptr) | |
| void | markChanged() |
| virtual void | setRangeFromVariant(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.
| Constant | Description |
|---|---|
QAbstractAxis::AxisTypeNoAxis | No axis. |
QAbstractAxis::AxisTypeValue | A QValueAxis. |
QAbstractAxis::AxisTypeBarCategory | A QBarCategoryAxis. |
QAbstractAxis::AxisTypeCategory | A category axis with ranges; Nt has none. |
QAbstractAxis::AxisTypeDateTime | A QDateTimeAxis. |
QAbstractAxis::AxisTypeLogValue | A QLogValueAxis. |
QAbstractAxis::AxisTypeColor | A color scale axis; Nt has none. |
typedef QAbstractAxis::AxisTypes
A QFlags of AxisType values.
Member Function Documentation
QAbstractAxis::QAbstractAxis(QObject *parent = nullptr)
Constructs an axis with the given parent. The axis does nothing until it is added to a chart.
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.
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.
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.
void QAbstractAxis::gridLinePenChanged(const QPen &pen)
This signal is emitted when the pen of the grid lines changes to pen.
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.
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.
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.
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.
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.
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.
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.
void QAbstractAxis::lineVisibleChanged(bool visible)
This signal is emitted when the axis line is shown or hidden; visible is the new state.
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.
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.
void QAbstractAxis::minorGridLinePenChanged(const QPen &pen)
This signal is emitted when the pen of the minor grid lines changes to pen.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
void QAbstractAxis::titleTextChanged(const QString &title)
This signal is emitted when the title text changes to title.
void QAbstractAxis::titleVisibleChanged(bool visible)
This signal is emitted when the title is shown or hidden; visible is the new state.
AxisType QAbstractAxis::type() const
Returns the type of the axis.
void QAbstractAxis::visibleChanged(bool visible)
This signal is emitted when the axis is shown or hidden; visible is the new state.