HPieModelMapper QML Type

Horizontal model mapper for pie series. More...

Import Statement: import QtCharts 2.5
Instantiates: QHPieModelMapper


Detailed Description

Model mappers enable using a data model derived from the QAbstractItemModel class as a data source for a chart. A horizontal model mapper is used to create a connection between a data model and PieSeries, so that each column in the data model defines a pie slice and each row 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 columns). Each slice gets a label from row 1 and a value from row 2.

HPieModelMapper {
    series: pieSeries
    model: customModel
    labelsRow: 1
    valuesRow: 2
    firstColumn: 1
    columnCount: 4

Property Documentation

columnCount : int

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

firstColumn : int

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

labelsRow : int

The row 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.

series : PieSeries

The PieSeries object 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 a new series is specified, the old series is disconnected (but it preserves its data).

valuesRow : int

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

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