QBarSet Class | Qt Charts 6.1.1

- Qt 6.1
- Qt Charts
- C++ Classes
- QBarSet
- Qt Charts | Commercial or GPLv3

# QBarSet Class

The QBarSet class represents one set of bars in a bar chart. More...

Header: | #include <QBarSet>
Instantiated By: | BarSet
Inherits: | QObject

- List of all members, including inherited members

## Properties

- borderColor : QColor
- brush : QBrush
- color : QColor
- label : QString

- labelBrush : QBrush
- labelColor : QColor
- labelFont : QFont
- pen : QPen

## Public Functions

| QBarSet(const QString label, QObject *parent = nullptr)
virtual | ~QBarSet()
void | append(const qreal value)
void | append(const QList<qreal> &values)
qreal | at(const int index) const
QColor | borderColor()
QBrush | brush() const
QColor | color()
int | count() const
void | insert(const int index, const qreal value)
QString | label() const
QBrush | labelBrush() const
QColor | labelColor()
QFont | labelFont() const
QPen | pen() const
void | remove(const int index, const int count = 1)
void | replace(const int index, const qreal value)
void | setBorderColor(QColor color)
void | setBrush(const QBrush &brush)
void | setColor(QColor color)
void | setLabel(const QString label)
void | setLabelBrush(const QBrush &brush)
void | setLabelColor(QColor color)
void | setLabelFont(const QFont &font)
void | setPen(const QPen &pen)
qreal | sum() const
QBarSet & | operator<<(const qreal &value)
qreal | operator[](const int index) const

## Signals

void | borderColorChanged(QColor color)
void | brushChanged()
void | clicked(int index)
void | colorChanged(QColor color)
void | doubleClicked(int index)
void | hovered(bool status, int index)
void | labelBrushChanged()
void | labelChanged()
void | labelColorChanged(QColor color)
void | labelFontChanged()
void | penChanged()
void | pressed(int index)
void | released(int index)
void | valueChanged(int index)
void | valuesAdded(int index, int count)
void | valuesRemoved(int index, int count)

## Detailed Description

A bar set contains one data value for each category. The first value of a set is assumed to belong to the first category, the second one to the second category, and so on. If the set has fewer values than there are categories, the missing values are assumed to be located at the end of the set. For missing values in the middle of a set, the numerical value of zero is used. Labels for zero value sets are not shown.

See also QAbstractBarSeries, QBarSeries, QStackedBarSeries, QPercentBarSeries, QHorizontalBarSeries, QHorizontalStackedBarSeries, and QHorizontalPercentBarSeries.

## Property Documentation

### borderColor : QColor

This property holds the line (pen) color of the bar set.

Access functions:

QColor | borderColor()
void | setBorderColor(QColor color)

Notifier signal:

void | borderColorChanged(QColor color)

### brush : QBrush

This property holds the brush used to fill the bars in the bar set.

Access functions:

QBrush | brush() const
void | setBrush(const QBrush &brush)

Notifier signal:

void | brushChanged()

### color : QColor

This property holds the fill (brush) color of the bar set.

Access functions:

QColor | color()
void | setColor(QColor color)

Notifier signal:

void | colorChanged(QColor color)

### label : QString

This property holds the label of the bar set.

Access functions:

QString | label() const
void | setLabel(const QString label)

Notifier signal:

void | labelChanged()

### labelBrush : QBrush

This property holds the brush used to draw the bar set's label.

Access functions:

QBrush | labelBrush() const
void | setLabelBrush(const QBrush &brush)

Notifier signal:

void | labelBrushChanged()

### labelColor : QColor

This property holds the text (label) color of the bar set.

Access functions:

QColor | labelColor()
void | setLabelColor(QColor color)

Notifier signal:

void | labelColorChanged(QColor color)

### labelFont : QFont

This property holds the font used to draw the bar set's label.

Access functions:

QFont | labelFont() const
void | setLabelFont(const QFont &font)

Notifier signal:

void | labelFontChanged()

### pen : QPen

This property holds the pen used to draw the lines of bars in the bar set.

Access functions:

QPen | pen() const
void | setPen(const QPen &pen)

Notifier signal:

void | penChanged()

## Member Function Documentation

### QBarSet::QBarSet(const QString label, QObject *parent = nullptr)

Constructs a bar set with the label label and the parent parent.

### `[signal]` void QBarSet::borderColorChanged(QColor color)

This signal is emitted when the line (pen) color of the bar set changes to color.

Note: Notifier signal for property borderColor.

### `[signal]` void QBarSet::brushChanged()

This signal is emitted when the brush used to draw the bar set changes.

Note: Notifier signal for property brush.

See also brush.

### `[signal]` void QBarSet::clicked(int index)

This signal is emitted when the user clicks the bar specified by index in a bar set.

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

This signal is emitted when the fill (brush) color of the bar set changes to color.

Note: Notifier signal for property color.

### `[signal]` void QBarSet::doubleClicked(int index)

This signal is emitted when the user double-clicks the bar specified by index in a bar set.

### `[signal]` void QBarSet::hovered(bool status, int index)

This signal is emitted when a mouse is hovered over the bar specified by index in a bar set. When the mouse moves over the bar, status turns `true`, and when the mouse moves away again, it turns `false`.

### `[signal]` void QBarSet::labelBrushChanged()

This signal is emitted when the brush used to draw the bar set's label changes.

Note: Notifier signal for property labelBrush.

See also labelBrush.

### `[signal]` void QBarSet::labelChanged()

This signal is emitted when the label of the bar set changes.

Note: Notifier signal for property label.

See also label.

### `[signal]` void QBarSet::labelColorChanged(QColor color)

This signal is emitted when the text (label) color of the bar set changes to color.

Note: Notifier signal for property labelColor.

### `[signal]` void QBarSet::labelFontChanged()

This signal is emitted when the font of the bar set's label changes.

Note: Notifier signal for property labelFont.

See also labelBrush.

### `[signal]` void QBarSet::penChanged()

This signal is emitted when the pen used to draw the bar set changes.

Note: Notifier signal for property pen.

See also pen.

### `[signal]` void QBarSet::pressed(int index)

This signal is emitted when the user clicks the bar specified by index in a bar set and holds down the mouse button.

### `[signal]` void QBarSet::released(int index)

This signal is emitted when the user releases the mouse press on the bar specified by index in a bar set.

### `[signal]` void QBarSet::valueChanged(int index)

This signal is emitted when the value at the position specified by index is modified.

See also at().

### `[signal]` void QBarSet::valuesAdded(int index, int count)

This signal is emitted when new values are added to the bar set. index indicates the position of the first inserted value, and count is the number of inserted values.

See also append() and insert().

### `[signal]` void QBarSet::valuesRemoved(int index, int count)

This signal is emitted when values are removed from the bar set. index indicates the position of the first removed value, and count is the number of removed values.

See also remove().

### `[virtual]` QBarSet::~QBarSet()

Removes the bar set.

### void QBarSet::append(const qreal value)

Appends the new value specified by value to the end of the bar set.

### void QBarSet::append(const QList<qreal> &values)

Appends the list of real values specified by values to the end of the bar set.

See also append().

### qreal QBarSet::at(const int index) const

Returns the value specified by index from the bar set. If the index is out of bounds, 0.0 is returned.

### QColor QBarSet::borderColor()

Returns the line color for the bar set.

Note: Getter function for property borderColor.

See also setBorderColor().

### QBrush QBarSet::brush() const

Returns the brush used to fill the bars in the bar set.

Note: Getter function for property brush.

See also setBrush().

### QColor QBarSet::color()

Returns the fill color for the bar set.

Note: Getter function for property color.

See also setColor().

### int QBarSet::count() const

Returns the number of values in a bar set.

### void QBarSet::insert(const int index, const qreal value)

Inserts value in the position specified by index. The values following the inserted value are moved up one position.

See also remove().

### QString QBarSet::label() const

Returns the label of the bar set.

Note: Getter function for property label.

See also setLabel().

### QBrush QBarSet::labelBrush() const

Returns the brush used to draw values on top of this bar set.

Note: Getter function for property labelBrush.

See also setLabelBrush().

### QColor QBarSet::labelColor()

Returns the text color for the bar set.

Note: Getter function for property labelColor.

See also setLabelColor().

### QFont QBarSet::labelFont() const

Returns the pen used to draw values on top of this bar set.

Note: Getter function for property labelFont.

See also setLabelFont().

### QPen QBarSet::pen() const

Returns the pen used to draw the lines in the bar set.

Note: Getter function for property pen.

See also setPen().

### void QBarSet::remove(const int index, const int count = 1)

Removes the number of values specified by count from the bar set starting with the value specified by index.

See also insert().

### void QBarSet::replace(const int index, const qreal value)

Adds the value specified by value to the bar set at the position specified by index.

### void QBarSet::setBorderColor(QColor color)

Sets the line color for the bar set to color.

Note: Setter function for property borderColor.

See also borderColor().

### void QBarSet::setBrush(const QBrush &brush)

Sets the brush used to fill the bars in the bar set to brush.

Note: Setter function for property brush.

See also brush().

### void QBarSet::setColor(QColor color)

Sets the fill color for the bar set to color.

Note: Setter function for property color.

See also color().

### void QBarSet::setLabel(const QString label)

Sets label as the new label for the bar set.

Note: Setter function for property label.

See also label().

### void QBarSet::setLabelBrush(const QBrush &brush)

Sets the brush used to draw values on top of this bar set to brush.

Note: Setter function for property labelBrush.

See also labelBrush().

### void QBarSet::setLabelColor(QColor color)

Sets the text color for the bar set to color.

Note: Setter function for property labelColor.

See also labelColor().

### void QBarSet::setLabelFont(const QFont &font)

Sets the font used to draw values on top of this bar set to font.

Note: Setter function for property labelFont.

See also labelFont().

### void QBarSet::setPen(const QPen &pen)

Sets the pen used to draw the lines in the bar set to pen.

Note: Setter function for property pen.

See also pen().

### qreal QBarSet::sum() const

Returns the sum of all values in the bar set.

### QBarSet &QBarSet::operator<<(const qreal &value)

A convenience operator for appending the real value specified by value to the end of the bar set.

See also append().

### qreal QBarSet::operator[](const int index) const

Returns the value of the bar set specified by index. If the index is out of bounds, 0.0 is returned.