QBarSet Class

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

Header: #include <QBarSet>
CMake: find_package(Qt6 REQUIRED COMPONENTS Graphs)
target_link_libraries(mytarget PRIVATE Qt6::Graphs)
qmake: QT += graphs
In QML: BarSet
Inherits: QObject

Properties

Public Functions

QBarSet(const QString &label, QObject *parent = nullptr)
virtual ~QBarSet() override
void append(const QList<qreal> &values)
void append(qreal value)
qreal at(qsizetype index) const
QColor borderColor() const
qreal borderWidth() const
void clear()
QColor color() const
qsizetype count() const
void deselectAllBars()
void deselectBar(qsizetype index)
void deselectBars(const QList<qsizetype> &indexes)
void insert(qsizetype index, qreal value)
bool isBarSelected(qsizetype index) const
QString label() const
QColor labelColor() const
void remove(qsizetype index, qsizetype count = 1)
void replace(qsizetype index, qreal value)
void selectAllBars()
void selectBar(qsizetype index)
void selectBars(const QList<qsizetype> &indexes)
QList<qsizetype> selectedBars() const
QColor selectedColor() const
void setBarSelected(qsizetype index, bool selected)
void setBorderColor(QColor color)
void setBorderWidth(qreal borderWidth)
void setColor(QColor color)
void setLabel(const QString &label)
void setLabelColor(QColor color)
void setSelectedColor(QColor color)
void setValues(const QVariantList &values)
qreal sum() const
void toggleSelection(const QList<qsizetype> &indexes)
QVariantList values() const
QBarSet &operator<<(qreal value)
qreal operator[](qsizetype index) const

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<qsizetype> &indexes)
void selectedColorChanged(QColor color)
void update()
void updatedBars()
void valueAdded(qsizetype index, qsizetype count)
void valueChanged(qsizetype index)
void valueRemoved(qsizetype index, qsizetype count)
void valuesAdded(qsizetype index, qsizetype count)
void valuesChanged()
void valuesRemoved(qsizetype index, qsizetype 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 QBarSeries.

Property Documentation

borderColor : QColor

This property holds the border color of the bar set.

Access functions:

QColor borderColor() const
void setBorderColor(QColor color)

Notifier signal:

void borderColorChanged(QColor color)

borderWidth : qreal

This property holds the width of the border line. By default, the width is -1, meaning the border width is defined by the theme.

Access functions:

qreal borderWidth() const
void setBorderWidth(qreal borderWidth)

Notifier signal:

void borderWidthChanged(qreal width)

color : QColor

This property holds the fill color of the bar set.

Access functions:

QColor color() const
void setColor(QColor color)

Notifier signal:

void colorChanged(QColor color)

[read-only] count : const qsizetype

This property holds the number of values in the bar set.

Access functions:

qsizetype count() const[see note below]

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

Notifier signal:

void countChanged()

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

Notifier signal:

void labelColorChanged(QColor color)

[read-only] selectedBars : const QList<qsizetype>

This property holds the indexes of the bars which are currently selected.

Access functions:

QList<qsizetype> selectedBars() const

Notifier signal:

void selectedBarsChanged(const QList<qsizetype> &indexes)

selectedColor : QColor

This property holds the fill color of the selected set.

Access functions:

QColor selectedColor() const
void setSelectedColor(QColor color)

Notifier signal:

void selectedColorChanged(QColor color)

values : QVariantList

This property holds the values of the bar set.

You can set a list of either real or point types as values.

If you set a list of real types as values, they directly define the bar set values.

If you set a list of point types as values, the x-coordinate of the point specifies its zero-based index in the bar set. The size of the bar set is the highest x-coordinate value + 1. If a point is missing for any x-coordinate between zero and the highest value, it gets the value zero.

Access functions:

QVariantList values() const
void setValues(const QVariantList &values)

Notifier signal:

void valuesChanged()

Member Function Documentation

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

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

[override virtual noexcept] QBarSet::~QBarSet()

Removes the bar set.

[invokable] void QBarSet::append(const QList<qreal> &values)

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

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also append().

[invokable] void QBarSet::append(qreal value)

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

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[invokable] qreal QBarSet::at(qsizetype index) const

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

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

QColor QBarSet::borderColor() const

Returns the line color for the bar set.

Note: Getter function for property borderColor.

See also setBorderColor().

[invokable] void QBarSet::clear()

Removes all values from the set.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

QColor QBarSet::color() const

Returns the fill color for the bar set.

Note: Getter function for property color.

See also setColor().

[invokable] qsizetype QBarSet::count() const

Returns the number of values in a bar set.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

Note: Getter function for property count.

[invokable] void QBarSet::deselectAllBars()

Deselects all bars in the set.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also setBarSelected().

[invokable] void QBarSet::deselectBar(qsizetype index)

Deselects the bar at index.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also setBarSelected().

[invokable] void QBarSet::deselectBars(const QList<qsizetype> &indexes)

Marks multiple bars passed in an indexes list as deselected.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also setBarSelected().

[invokable] void QBarSet::insert(qsizetype index, qreal value)

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

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also remove().

[invokable] bool QBarSet::isBarSelected(qsizetype 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.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

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

Returns the text color for the bar set.

Note: Getter function for property labelColor.

See also setLabelColor().

[invokable] void QBarSet::remove(qsizetype index, qsizetype count = 1)

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

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also insert().

[invokable] void QBarSet::replace(qsizetype index, qreal value)

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

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[invokable] void QBarSet::selectAllBars()

Marks all bars in the set as selected.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also setBarSelected().

[invokable] void QBarSet::selectBar(qsizetype index)

Marks the bar at index as selected.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also setBarSelected().

[invokable] void QBarSet::selectBars(const QList<qsizetype> &indexes)

Marks multiple bars passed in an indexes list as selected.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also setBarSelected().

QList<qsizetype> QBarSet::selectedBars() const

Returns a list of bars marked as selected.

Note: Getter function for property selectedBars.

See also setBarSelected().

[signal] void QBarSet::selectedBarsChanged(const QList<qsizetype> &indexes)

This signal is emitted when the selected bar changes. indexes is a list selected bar indexes.

Note: Notifier signal for property selectedBars.

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.

Note: Getter function for property selectedColor.

See also setSelectedColor() and color.

[invokable] void QBarSet::setBarSelected(qsizetype 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.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

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

Sets the color of the selected bars.

Note: Setter function for property selectedColor.

See also selectedColor.

[invokable] qreal QBarSet::sum() const

Returns the sum of all values in the bar set.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[invokable] void QBarSet::toggleSelection(const QList<qsizetype> &indexes)

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

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also setBarSelected().

[signal] void QBarSet::update()

This signal is emitted when the barset is updated.

[signal] void QBarSet::updatedBars()

This signal is emitted when the bars in this set are updated.

[signal] void QBarSet::valueAdded(qsizetype index, qsizetype 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.

[signal] void QBarSet::valueChanged(qsizetype index)

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

See also at().

[signal] void QBarSet::valueRemoved(qsizetype index, qsizetype 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.

[signal] void QBarSet::valuesAdded(qsizetype index, qsizetype 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(qsizetype index, qsizetype 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().

QBarSet &QBarSet::operator<<(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[](qsizetype index) const

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

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.