QBarModelMapper Class | Qt Graphs | Qt 6.11.0
Description: The QBarModelMapper class is a model mapper for bar series.

- Qt 6.11
- Qt Graphs
- C++ Classes
- QtGraphs
- QBarModelMapper
- Qt Graphs | Commercial or GPLv3

# QBarModelMapper Class

The QBarModelMapper class is a model mapper for bar series. More...

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

- List of all members, including inherited members
- QBarModelMapper is part of Qt Graphs C++ Classes for 2D.

## Properties

count : qsizetype first : qsizetype firstBarSetSection : qsizetype lastBarSetSection : qsizetype | model : QAbstractItemModel* orientation : Qt::Orientation series : QBarSeries*

## Public Functions

qsizetype | count() const
qsizetype | first() const
qsizetype | firstBarSetSection() const
qsizetype | lastBarSetSection() const
QAbstractItemModel * | model() const
Qt::Orientation | orientation() const
QBarSeries * | series() const
void | setCount(qsizetype newCount)
void | setFirst(qsizetype newFirst)
void | setFirstBarSetSection(qsizetype newFirstBarSetSection)
void | setLastBarSetSection(qsizetype newLastBarSetSection)
void | setModel(QAbstractItemModel *model)
void | setOrientation(Qt::Orientation orientation)
void | setSeries(QBarSeries *series)

## Signals

void | countChanged()
void | firstBarSetSectionChanged()
void | firstChanged()
void | lastBarSetSectionChanged()
void | modelChanged()
void | orientationChanged()
void | seriesChanged()

## Detailed Description

Model mappers enable using a data model derived from the QAbstractItemModel class as a data source for a graph. A model mapper is used to create a connection between a data model and QBarSeries.

Both model and bar series properties can be used to manipulate the data. The model mapper keeps the bar series and the data model in sync.

The model mapper ensures that all the bar sets in the bar series have equal sizes. Therefore, adding or removing a value from a bar set causes the same change to be made in all the bar sets in the bar series.

## Property Documentation

### count : qsizetype

This property holds the number of rows or columns of the model that are mapped as the data for the bar series.

The default value is `-1` which is also the minimum. The count is limited by the number of model's rows/columns.

Access functions:

qsizetype | count() const
void | setCount(qsizetype newCount)

Notifier signal:

void | countChanged()

See also QBarModelMapper::orientation.

### first : qsizetype

This property holds the row or column of the model that contains the first values of the bar sets in the bar series.

The minimum and default value is 0.

Access functions:

qsizetype | first() const
void | setFirst(qsizetype newFirst)

Notifier signal:

void | firstChanged()

See also QBarModelMapper::orientation.

### firstBarSetSection : qsizetype

This property holds the section of the model that is used as the data source for the first bar set.

The default value is -1 (invalid mapping).

Access functions:

qsizetype | firstBarSetSection() const
void | setFirstBarSetSection(qsizetype newFirstBarSetSection)

Notifier signal:

void | firstBarSetSectionChanged()

See also QBarModelMapper::orientation.

### lastBarSetSection : qsizetype

This property holds the section of the model that is used as the data source for the last bar set.

The default value is -1 (invalid mapping).

Access functions:

qsizetype | lastBarSetSection() const
void | setLastBarSetSection(qsizetype newLastBarSetSection)

Notifier signal:

void | lastBarSetSectionChanged()

See also QBarModelMapper::orientation.

### model : QAbstractItemModel*

This property holds the data model that is used by the mapper.

Access functions:

QAbstractItemModel * | model() const
void | setModel(QAbstractItemModel *model)

Notifier signal:

void | modelChanged()

### orientation : Qt::Orientation

Tells the modelmapper how to map data from a model. If `Qt::Vertical` is used, each of the model's columns defines a bar set, and the model's rows define the categories. When the orientation is set to `Qt::Horizontal`, each of the model's rows defines a bar set, and the model's columns define categories.

The default value is `Qt::Vertical`

Access functions:

Qt::Orientation | orientation() const
void | setOrientation(Qt::Orientation orientation)

Notifier signal:

void | orientationChanged()

### series : QBarSeries*

This property holds the bar series that is used by the mapper.

All the data in the series is discarded when it is set to the mapper. When a new series is specified, the old series is disconnected, but it preserves its data.

Access functions:

QBarSeries * | series() const
void | setSeries(QBarSeries *series)

Notifier signal:

void | seriesChanged()