QBarSet Class

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

Header: #include <QBarSet>
CMake: find_package(Qt6 REQUIRED COMPONENTS Graphs)
target_link_libraries(mytarget PRIVATE Qt6::Graphs)
qmake: QT += graphs
Instantiated By: BarSet
Inherits: QObject
Status: Technical Preview

Properties

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()
qreal borderWidth() const
QColor color()
int count() const
void insert(const int index, const qreal value)
QString label() const
QColor labelColor()
void remove(const int index, const int count = 1)
void replace(const int index, const qreal value)
QColor selectedColor() const
void setBorderColor(QColor color)
void setBorderWidth(qreal borderWidth)
void setColor(QColor color)
void setLabel(const QString label)
void setLabelColor(QColor color)
void setSelectedColor(const QColor &color)
void setValues(QVariantList values)
qreal sum() const
QVariantList values()
QBarSet &operator<<(const qreal &value)
qreal operator[](const int index) const

Public Slots

void deselectAllBars()
void deselectBar(int index)
void deselectBars(const QList<int> &indexes)
bool isBarSelected(int index) const
void selectAllBars()
void selectBar(int index)
void selectBars(const QList<int> &indexes)
QList<int> selectedBars() const
void setBarSelected(int index, bool selected)
void toggleSelection(const QList<int> &indexes)

Signals

void borderColorChanged(QColor color)
void borderWidthChanged(qreal width)
void colorChanged(QColor color)
void countChanged()
void labelChanged()
void labelColorChanged(QColor color)
void selectedBarsChanged(const QList<int> &indexes)

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)

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()

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)

Member Function Documentation

[explicit] QBarSet::QBarSet(const QString label, QObject *parent = nullptr)

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

[virtual noexcept] 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().

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.

Note: Getter function for property count.

[slot] void QBarSet::deselectAllBars()

Deselects all bars in the series.

See also setBarSelected().

[slot] void QBarSet::deselectBar(int index)

Deselects the bar at index.

See also setBarSelected().

[slot] void QBarSet::deselectBars(const QList<int> &indexes)

Marks multiple bars passed in an indexes list as deselected.

See also setBarSelected().

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().

[slot] bool QBarSet::isBarSelected(int index) const

Returns true if the bar at the given index is among selected bars and false otherwise.

Note: Selected bars are drawn using the selected color if it was specified using QBarSet::setSelectedColor.

See also selectedBars(), setBarSelected(), and setSelectedColor().

QString QBarSet::label() const

Returns the label of the bar set.

Note: Getter function for property label.

See also setLabel().

QColor QBarSet::labelColor()

Returns the text color for the bar set.

Note: Getter function for property labelColor.

See also setLabelColor().

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.

[slot] void QBarSet::selectAllBars()

Marks all bars in the series as selected.

See also setBarSelected().

[slot] void QBarSet::selectBar(int index)

Marks the bar at index as selected.

See also setBarSelected().

[slot] void QBarSet::selectBars(const QList<int> &indexes)

Marks multiple bars passed in an indexes list as selected.

See also setBarSelected().

[slot] QList<int> QBarSet::selectedBars() const

Returns a list of bars marked as selected.

Note: Getter function for property selectedBars.

See also setBarSelected().

QColor QBarSet::selectedColor() const

Returns the color of the selected bars.

This is the fill (brush) color of bars marked as selected. If not specified, value of QBarSet::color is used as default.

See also setSelectedColor() and color.

[slot] void QBarSet::setBarSelected(int index, bool selected)

Marks the bar at index as either selected or deselected as specified by selected.

Note: Selected bars are drawn using the selected color if it was specified. Emits QBarSet::selectedBarsChanged.

See also isBarSelected() and setSelectedColor().

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::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::setLabelColor(QColor color)

Sets the text color for the bar set to color.

Note: Setter function for property labelColor.

See also labelColor().

void QBarSet::setSelectedColor(const QColor &color)

Sets the color of the selected bars.

See also selectedColor.

qreal QBarSet::sum() const

Returns the sum of all values in the bar set.

[slot] void QBarSet::toggleSelection(const QList<int> &indexes)

Changes the selection state of bars at the given indexes to the opposite one.

See also setBarSelected().

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.