- Qt 6.9
- Qt Graphs
- QML Types
- QtGraphs
- PieModelMapper
- Qt Graphs | Commercial or GPLv3

# PieModelMapper QML Type

Model mapper for pie series. More...

Import Statement: | `import QtGraphs`
In C++: | QPieModelMapper

- List of all members, including inherited members
- PieModelMapper is part of Qt Graphs QML Types for 2D.

## Properties

- count : qsizetype
- first : qsizetype
- labelsSection : qsizetype
- model : model
- orientation : orientation
- series : PieSeries
- valuesSection : qsizetype

## Signals

- countChanged()
- firstChanged()
- labelsSectionChanged()
- modelChanged()
- orientationChanged()
- seriesChanged()
- valuesSectionChanged()

## 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 PieSeries.

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

The following QML example creates a pie series with four slices (assuming the model has at least five rows). Each slice gets a label from column 1 and a value from column 2.

     PieModelMapper {
         series: pieSeries
         model: customModel
         labelsSection: 1
         valuesSection: 2
         first: 1
         count: 4
         orientation: Qt.Vertical
     }

## Property Documentation

count : qsizetype

The number of columns or rows of the model that are mapped as the data for a pie series. The default value is -1 (number limited by the number of rows in the model).

See also orientation.

first : qsizetype

The column or row of the model that contains the first slice value. The default value is 0.

See also orientation.

labelsSection : qsizetype

The column or row of the model that is kept in sync with the labels of the pie's slices. The default value is -1 (invalid mapping).

See also orientation.

model : model

The QAbstractItemModel based model that is used by the mapper. You need to implement the model and expose it to QML.

Note: The model has to support adding and removing rows or columns and modifying the data in the cells.

orientation : orientation

Tells the modelmapper how to map data from a model. If `Qt.Vertical` is used, each of the model's rows defines a pie slice, and the model's columns define the label or the value of the pie slice. When the orientation is set to `Qt.Horizontal`, each of the model's columns defines a pie slice, and the model's rows define the label or the value of the pie slice.

The default value is `Qt.Vertical`

series : PieSeries

The pie series that is used by the mapper. If you define the mapper element as a child for a PieSeries, leave this property undefined. All the data in the series is discarded when it is set to the mapper. When new series is specified the old series is disconnected (but it preserves its data).

valuesSection : qsizetype

The column or row of the model that is kept in sync with the values of the pie's slices. The default value is -1 (invalid mapping).

See also orientation.

## Signal Documentation

countChanged()

This signal is emitted when the count changes.

Note: The corresponding handler is `onCountChanged`.

firstChanged()

This signal is emitted when the first slice changes.

Note: The corresponding handler is `onFirstChanged`.

labelsSectionChanged()

This signal is emitted when the labels section changes.

Note: The corresponding handler is `onLabelsSectionChanged`.

modelChanged()

This signal is emitted when the model that the mapper is connected to changes.

Note: The corresponding handler is `onModelChanged`.

orientationChanged()

This signal is emitted when the orientation changes.

Note: The corresponding handler is `onOrientationChanged`.

seriesChanged()

This signal is emitted when the series that the mapper is connected to changes.

Note: The corresponding handler is `onSeriesChanged`.

valuesSectionChanged()

This signal is emitted when the values section changes.

Note: The corresponding handler is `onValuesSectionChanged`.