QAbstractAxis Class | Qt Charts 5.7

Qt 5.7 | Qt Charts | C++ Classes | QAbstractAxis

Qt 5.7.1 Reference Documentation

# QAbstractAxis Class

The QAbstractAxis class is used for manipulating chart's axis. More...

Header: | #include <QAbstractAxis>
Instantiated By: | AbstractAxis
Inherits: | QObject
Inherited By: | QBarCategoryAxis, QDateTimeAxis, QLogValueAxis, and QValueAxis

- List of all members, including inherited members

## Public Types

enum | AxisType { AxisTypeNoAxis, AxisTypeValue, AxisTypeBarCategory, AxisTypeCategory, AxisTypeDateTime, AxisTypeLogValue }
flags | AxisTypes

## Properties

- alignment : const Qt::Alignment
- color : QColor
- gridLineColor : QColor
- gridLinePen : QPen
- gridVisible : bool
- labelsAngle : int
- labelsBrush : QBrush
- labelsColor : QColor
- labelsFont : QFont
- labelsVisible : bool
- linePen : QPen
- lineVisible : bool
- minorGridLineColor : QColor
- minorGridLinePen : QPen

- minorGridVisible : bool
- orientation : const Qt::Orientation
- reverse : bool
- shadesBorderColor : QColor
- shadesBrush : QBrush
- shadesColor : QColor
- shadesPen : QPen
- shadesVisible : bool
- titleBrush : QBrush
- titleFont : QFont
- titleText : QString
- titleVisible : bool
- visible : bool

- 1 property inherited from QObject

## Public Functions

| ~QAbstractAxis()
Qt::Alignment | alignment() const
QColor | gridLineColor()
QPen | gridLinePen() const
void | hide()
bool | isGridLineVisible() const
bool | isLineVisible() const
bool | isMinorGridLineVisible() const
bool | isReverse() const
bool | isTitleVisible() const
bool | isVisible() const
int | labelsAngle() const
QBrush | labelsBrush() const
QColor | labelsColor() const
QFont | labelsFont() const
bool | labelsVisible() const
QPen | linePen() const
QColor | linePenColor() const
QColor | minorGridLineColor()
QPen | minorGridLinePen() const
Qt::Orientation | orientation() const
void | setGridLineColor(const QColor &color)
void | setGridLinePen(const QPen &pen)
void | setGridLineVisible(bool visible = true)
void | setLabelsAngle(int angle)
void | setLabelsBrush(const QBrush &brush)
void | setLabelsColor(QColor color)
void | setLabelsFont(const QFont &font)
void | setLabelsVisible(bool visible = true)
void | setLinePen(const QPen &pen)
void | setLinePenColor(QColor color)
void | setLineVisible(bool visible = true)
void | setMax(const QVariant &max)
void | setMin(const QVariant &min)
void | setMinorGridLineColor(const QColor &color)
void | setMinorGridLinePen(const QPen &pen)
void | setMinorGridLineVisible(bool visible = true)
void | setRange(const QVariant &min, const QVariant &max)
void | setReverse(bool reverse = true)
void | setShadesBorderColor(QColor color)
void | setShadesBrush(const QBrush &brush)
void | setShadesColor(QColor color)
void | setShadesPen(const QPen &pen)
void | setShadesVisible(bool visible = true)
void | setTitleBrush(const QBrush &brush)
void | setTitleFont(const QFont &font)
void | setTitleText(const QString &title)
void | setTitleVisible(bool visible = true)
void | setVisible(bool visible = true)
QColor | shadesBorderColor() const
QBrush | shadesBrush() const
QColor | shadesColor() const
QPen | shadesPen() const
bool | shadesVisible() const
void | show()
QBrush | titleBrush() const
QFont | titleFont() const
QString | titleText() const
virtual AxisType | type() const = 0

- 31 public functions inherited from QObject

## Signals

void | colorChanged(QColor color)
void | gridLineColorChanged(const QColor &color)
void | gridLinePenChanged(const QPen &pen)
void | gridVisibleChanged(bool visible)
void | labelsAngleChanged(int angle)
void | labelsBrushChanged(const QBrush &brush)
void | labelsColorChanged(QColor color)
void | labelsFontChanged(const QFont &font)
void | labelsVisibleChanged(bool visible)
void | linePenChanged(const QPen &pen)
void | lineVisibleChanged(bool visible)
void | minorGridLineColorChanged(const QColor &color)
void | minorGridLinePenChanged(const QPen &pen)
void | minorGridVisibleChanged(bool visible)
void | reverseChanged(bool reverse)
void | shadesBorderColorChanged(QColor color)
void | shadesBrushChanged(const QBrush &brush)
void | shadesColorChanged(QColor color)
void | shadesPenChanged(const QPen &pen)
void | shadesVisibleChanged(bool visible)
void | titleBrushChanged(const QBrush &brush)
void | titleFontChanged(const QFont &font)
void | titleTextChanged(const QString &text)
void | titleVisibleChanged(bool visible)
void | visibleChanged(bool visible)

- 2 signals inherited from QObject

### Additional Inherited Members

- 1 public slot inherited from QObject
- 1 public variable inherited from QObject
- 10 static public members inherited from QObject
- 9 protected functions inherited from QObject
- 2 protected variables inherited from QObject

## Detailed Description

The QAbstractAxis class is used for manipulating chart's axis.

Each series can be bound to one or more horizontal and vertical axes, but mixing axis types that would result in different domains is not supported, such as specifying QValueAxis and QLogValueAxis on the same orientation.

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

## Member Type Documentation

### enum QAbstractAxis::AxisType
flags QAbstractAxis::AxisTypes

The type of the axis object.

Constant | Value
--- | ---
`QAbstractAxis::AxisTypeNoAxis` | `0x0`
`QAbstractAxis::AxisTypeValue` | `0x1`
`QAbstractAxis::AxisTypeBarCategory` | `0x2`
`QAbstractAxis::AxisTypeCategory` | `0x4`
`QAbstractAxis::AxisTypeDateTime` | `0x8`
`QAbstractAxis::AxisTypeLogValue` | `0x10`

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

## Property Documentation

### alignment : const Qt::Alignment

The alignment of the axis. Can be Qt::AlignLeft, Qt::AlignRight, Qt::AlignBottom, or Qt::AlignTop.

Access functions:

Qt::Alignment | alignment() const

### color : QColor

The color of the axis and ticks.

Access functions:

QColor | linePenColor() const
void | setLinePenColor(QColor color)

Notifier signal:

void | colorChanged(QColor color)

### gridLineColor : QColor

The color of the grid line.

Access functions:

QColor | gridLineColor()
void | setGridLineColor(const QColor &color)

Notifier signal:

void | gridLineColorChanged(const QColor &color)

### gridLinePen : QPen

The pen of the grid line.

Access functions:

QPen | gridLinePen() const
void | setGridLinePen(const QPen &pen)

Notifier signal:

void | gridLinePenChanged(const QPen &pen)

### gridVisible : bool

The visibility of the grid lines.

Access functions:

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

Notifier signal:

void | gridVisibleChanged(bool visible)

### labelsAngle : int

The angle of the axis labels in degrees.

Access functions:

int | labelsAngle() const
void | setLabelsAngle(int angle)

Notifier signal:

void | labelsAngleChanged(int angle)

### labelsBrush : QBrush

The brush of the labels. Only the color of the brush is relevant.

Access functions:

QBrush | labelsBrush() const
void | setLabelsBrush(const QBrush &brush)

Notifier signal:

void | labelsBrushChanged(const QBrush &brush)

### labelsColor : QColor

The color of the axis labels.

Access functions:

QColor | labelsColor() const
void | setLabelsColor(QColor color)

Notifier signal:

void | labelsColorChanged(QColor color)

### labelsFont : QFont

The font of the axis labels.

Access functions:

QFont | labelsFont() const
void | setLabelsFont(const QFont &font)

Notifier signal:

void | labelsFontChanged(const QFont &font)

### labelsVisible : bool

Defines if axis labels are visible.

Access functions:

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

Notifier signal:

void | labelsVisibleChanged(bool visible)

### linePen : QPen

The pen of the line.

Access functions:

QPen | linePen() const
void | setLinePen(const QPen &pen)

Notifier signal:

void | linePenChanged(const QPen &pen)

### lineVisible : bool

The visibility of the axis line

Access functions:

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

Notifier signal:

void | lineVisibleChanged(bool visible)

### minorGridLineColor : QColor

The color of the minor grid line. Applies only to QValueAxis.

Access functions:

QColor | minorGridLineColor()
void | setMinorGridLineColor(const QColor &color)

Notifier signal:

void | minorGridLineColorChanged(const QColor &color)

### minorGridLinePen : QPen

The pen of the minor grid line. Applies only to QValueAxis.

Access functions:

QPen | minorGridLinePen() const
void | setMinorGridLinePen(const QPen &pen)

Notifier signal:

void | minorGridLinePenChanged(const QPen &pen)

### minorGridVisible : bool

The visibility of the minor grid lines. Applies only to QValueAxis.

Access functions:

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

Notifier signal:

void | minorGridVisibleChanged(bool visible)

### orientation : const Qt::Orientation

The orientation of the axis. Fixed to either Qt::Horizontal or Qt::Vertical when you add the axis to a chart.

Access functions:

Qt::Orientation | orientation() const

### reverse : bool

The reverse property defines if reverse axis is used. By default the value is false.

Reverse axis is supported with line, spline, scatter and area series with cartesian chart. All axes of the same orientation attached to same series must be reversed if one is reversed or the behavior is undefined.

Access functions:

bool | isReverse() const
void | setReverse(bool reverse = true)

Notifier signal:

void | reverseChanged(bool reverse)

### shadesBorderColor : QColor

The border (pen) color of the axis shades.

Access functions:

QColor | shadesBorderColor() const
void | setShadesBorderColor(QColor color)

Notifier signal:

void | shadesBorderColorChanged(QColor color)

### shadesBrush : QBrush

The brush of the axis shades (area between grid lines).

Access functions:

QBrush | shadesBrush() const
void | setShadesBrush(const QBrush &brush)

Notifier signal:

void | shadesBrushChanged(const QBrush &brush)

### shadesColor : QColor

The fill (brush) color of the axis shades.

Access functions:

QColor | shadesColor() const
void | setShadesColor(QColor color)

Notifier signal:

void | shadesColorChanged(QColor color)

### shadesPen : QPen

The pen of the axis shades (area between grid lines).

Access functions:

QPen | shadesPen() const
void | setShadesPen(const QPen &pen)

Notifier signal:

void | shadesPenChanged(const QPen &pen)

### shadesVisible : bool

The visibility of the axis shades.

Access functions:

bool | shadesVisible() const
void | setShadesVisible(bool visible = true)

Notifier signal:

void | shadesVisibleChanged(bool visible)

### titleBrush : QBrush

The brush of the title text. Only the color of the brush is relevant.

Access functions:

QBrush | titleBrush() const
void | setTitleBrush(const QBrush &brush)

Notifier signal:

void | titleBrushChanged(const QBrush &brush)

### titleFont : QFont

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

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

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

The visibility of the axis.

Access functions:

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

Notifier signal:

void | visibleChanged(bool visible)

## Member Function Documentation

### QAbstractAxis::~QAbstractAxis()

Destructor of the axis object. When axis is added to chart, chart object takes ownership.

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

Emitted if the color of the axis is changed.

Note: Notifier signal for property color.

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

The color of the pen of the grid line has changed to color.

Note: Notifier signal for property gridLineColor.

### QPen QAbstractAxis::gridLinePen() const

Returns pen used to draw grid.

Note: Getter function for property gridLinePen.

See also setGridLinePen().

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

The pen of the grid line has changed to pen.

Note: Notifier signal for property gridLinePen.

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

Visibility of the grid lines of the axis has changed to visible.

Note: Notifier signal for property gridVisible.

### void QAbstractAxis::hide()

Sets axis, shades, labels and grid lines to not be visible.

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

The angle of the axis labels has changed to angle.

Note: Notifier signal for property labelsAngle.

### QBrush QAbstractAxis::labelsBrush() const

Returns brush used to draw labels.

Note: Getter function for property labelsBrush.

See also setLabelsBrush().

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

The brush of the axis labels has changed to brush.

Note: Notifier signal for property labelsBrush.

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

Emitted if the color of the axis labels is changed.

Note: Notifier signal for property labelsColor.

### QFont QAbstractAxis::labelsFont() const

Returns font used to draw labels.

Note: Getter function for property labelsFont.

See also setLabelsFont().

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

The font of the axis labels has changed to font.

Note: Notifier signal for property labelsFont.

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

Visibility of the labels of the axis has changed to visible.

Note: Notifier signal for property labelsVisible.

### QPen QAbstractAxis::linePen() const

Returns pen used to draw axis and ticks.

Note: Getter function for property linePen.

See also setLinePen().

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

The pen of the line of the axis has changed to pen.

Note: Notifier signal for property linePen.

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

Visibility of the axis line has changed to visible.

Note: Notifier signal for property lineVisible.

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

The color of the pen of the minor grid line has changed to color.

Note: Notifier signal for property minorGridLineColor.

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

The pen of the minor grid line has changed to pen.

Note: Notifier signal for property minorGridLinePen.

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

Visibility of the minor grid lines of the axis has changed to visible.

Note: Notifier signal for property minorGridVisible.

### Qt::Orientation QAbstractAxis::orientation() const

Returns the orientation in which the axis is being used (Vertical or Horizontal)

Note: Getter function for property orientation.

### void QAbstractAxis::setGridLinePen(const QPen &pen)

Sets pen used to draw grid line.

Note: Setter function for property gridLinePen.

See also gridLinePen().

### void QAbstractAxis::setLabelsBrush(const QBrush &brush)

Sets brush used to draw labels.

Note: Setter function for property labelsBrush.

See also labelsBrush().

### void QAbstractAxis::setLabelsFont(const QFont &font)

Sets font used to draw labels.

Note: Setter function for property labelsFont.

See also labelsFont().

### void QAbstractAxis::setLinePen(const QPen &pen)

Sets pen used to draw axis line and ticks.

Note: Setter function for property linePen.

See also linePen().

### void QAbstractAxis::setLineVisible(bool visible = true)

Sets if axis and ticks 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 appropriate type. If the conversion is impossible then 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 appropriate type. If the conversion is impossible then 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. If the conversion is impossible then the function call does nothing.

### void QAbstractAxis::setShadesBrush(const QBrush &brush)

Sets brush used to draw shades.

Note: Setter function for property shadesBrush.

See also shadesBrush().

### void QAbstractAxis::setShadesPen(const QPen &pen)

Sets pen used to draw shades.

Note: Setter function for property shadesPen.

See also shadesPen().

### void QAbstractAxis::setTitleBrush(const QBrush &brush)

Sets brush used to draw title.

Note: Setter function for property titleBrush.

See also titleBrush().

### void QAbstractAxis::setTitleFont(const QFont &font)

Sets font used to draw title.

Note: Setter function for property titleFont.

See also titleFont().

### void QAbstractAxis::setVisible(bool visible = true)

Sets axis, shades, labels and grid lines visibility to visible.

Note: Setter function for property visible.

See also isVisible().

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

Emitted if the border color of the axis shades is changed.

Note: Notifier signal for property shadesBorderColor.

### QBrush QAbstractAxis::shadesBrush() const

Returns brush used to draw shades.

Note: Getter function for property shadesBrush.

See also setShadesBrush().

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

The brush of the axis shades has changed to brush.

Note: Notifier signal for property shadesBrush.

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

Emitted if the color of the axis shades is changed.

Note: Notifier signal for property shadesColor.

### QPen QAbstractAxis::shadesPen() const

Returns pen used to draw shades.

Note: Getter function for property shadesPen.

See also setShadesPen().

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

The pen of the axis shades has changed to pen.

Note: Notifier signal for property shadesPen.

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

Emitted if the visibility of the axis shades is changed to visible.

Note: Notifier signal for property shadesVisible.

### void QAbstractAxis::show()

Sets axis, shades, labels and grid lines to be visible.

### QBrush QAbstractAxis::titleBrush() const

Returns brush used to draw title.

Note: Getter function for property titleBrush.

See also setTitleBrush().

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

The brush of the axis title has changed to brush.

Note: Notifier signal for property titleBrush.

### QFont QAbstractAxis::titleFont() const

Returns font used to draw title.

Note: Getter function for property titleFont.

See also setTitleFont().

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

The font of the axis title has changed to font.

Note: Notifier signal for property titleFont.

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

The text of the axis title has changed to text.

Note: Notifier signal for property titleText.

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

Visibility of the title text of the axis has changed to visible.

Note: Notifier signal for property titleVisible.

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

* Returns the type of the axis

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

Visibility of the axis has changed to visible.

Note: Notifier signal for property visible.