- Qt 6.9
- Qt Graphs
- C++ Classes
- QtGraphs
- QXYModelMapper
- Qt Graphs | Commercial or GPLv3

# QXYModelMapper Class

The QXYModelMapper class is a model mapper for line, spline, and scatter series. More...

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

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

## Properties

- count : qsizetype
- first : qsizetype
- model : QAbstractItemModel*
- orientation : Qt::Orientation

- series : QXYSeries*
- xSection : qsizetype
- ySection : qsizetype

## Public Functions

qsizetype | count() const
qsizetype | first() const
QAbstractItemModel * | model() const
Qt::Orientation | orientation() const
QXYSeries * | series() const
void | setCount(qsizetype count)
void | setFirst(qsizetype first)
void | setModel(QAbstractItemModel *model)
void | setOrientation(Qt::Orientation orientation)
void | setSeries(QXYSeries *series)
void | setXSection(qsizetype xSection)
void | setYSection(qsizetype ySection)
qsizetype | xSection() const
qsizetype | ySection() const

## Signals

void | countChanged()
void | firstChanged()
void | modelChanged()
void | orientationChanged()
void | seriesChanged()
void | xSectionChanged()
void | ySectionChanged()

## 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 line, spline, or scatter series. A TableModel is a natural choice for the model.

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

See also QXYSeries.

## Property Documentation

### count : qsizetype

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

The minimum and default value is -1 (the number is limited by the number of rows in the model).

Access functions:

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

Notifier signal:

void | countChanged()

See also QXYModelMapper::orientation.

### first : qsizetype

This property holds the row of the model that contains the data for the first point of the series.

The minimum and default value is 0.

Access functions:

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

Notifier signal:

void | firstChanged()

See also QXYModelMapper::orientation.

### model : QAbstractItemModel*

This property holds the 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 : QXYSeries*

This property holds the 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:

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

Notifier signal:

void | seriesChanged()

### xSection : qsizetype

This property holds the section of the model that contains the x-coordinates of data points.

The default value is -1 (invalid mapping).

Access functions:

qsizetype | xSection() const
void | setXSection(qsizetype xSection)

Notifier signal:

void | xSectionChanged()

See also QXYModelMapper::orientation.

### ySection : qsizetype

This property holds the section of the model that contains the y-coordinates of data points.

The default value is -1 (invalid mapping).

Access functions:

qsizetype | ySection() const
void | setYSection(qsizetype ySection)

Notifier signal:

void | ySectionChanged()

See also QXYModelMapper::orientation.