##// END OF EJS Templates
Docs update after classes renaming
Docs update after classes renaming

File last commit:

r1385:c13c825c33e5
r1812:329e3a076da0
Show More
demos-qmlcustommodel.qdoc
29 lines | 1.5 KiB | text/plain | TextLexer
/ doc / src / demos-qmlcustommodel.qdoc
Tero Ahola
Documentation for QML custom model demo
r1385 /*!
\example demos/qmlcustommodel
\title QML Custom Model
\subtitle
This example shows how to use your own QAbstractItemModel derived data model as a data source for a ChartView.
\image demos_qmlcustommodel.png
First we create a ChartView:
\snippet ../demos/qmlcustommodel/qml/qmlcustommodel/main.qml 1
Then our data model that contains the shares of top-5 car manufacturers in Finland for the last 5 years. The model
could be constructed from various sources depending on the use case, but here we use static data for the sake of
simplicity. Check customtablemodel.cpp, declarativemodel.cpp and plugin.cpp to see how to make your own
QAbstractItemModel accessible on QML.
\snippet ../demos/qmlcustommodel/qml/qmlcustommodel/main.qml 2
Then we create several series as children for the same ChartView. First a pie series that illustrates the shares of
the car manufacturers in Finland in 2011:
\snippet ../demos/qmlcustommodel/qml/qmlcustommodel/main.qml 3
And one line series for each manufacturer presenting the share between 2007-2011, for example this one is for
Volkswagen. The series is not visible by default; it is made visible when the user clicks on the Volkswagen slice
on the pie series:
\snippet ../demos/qmlcustommodel/qml/qmlcustommodel/main.qml 4
And finally a bar series that shows the share for all the other manufacturers between 2007-2011:
\snippet ../demos/qmlcustommodel/qml/qmlcustommodel/main.qml 5
*/