Vertical model mapper for pie series. More...

Import Statement: import QtCharts 2.2
Instantiates: QVPieModelMapper


Detailed Description

Model mappers enable using a data model derived from the QAbstractItemModel class as a data source for a chart. A vertical model mapper is used to create a connection between a data model and PieSeries, so that each row in the data model defines a pie slice and each column maps to the label or the value of the pie slice.

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.

VPieModelMapper {
    series: pieSeries
    model: customModel
    labelsColumn: 1
    valuesColumn: 2
    firstRow: 1
    rowCount: 4

Property Documentation

firstRow : int

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

labelsColumn : int

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

model : SomeModel

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.

rowCount : int

The number of 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).

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

valuesColumn : int

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

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
create apps
create games
cross platform
native performance
3rd party services
game network
level editor
easiest to learn
biggest time saving
best support