@@ -58,20 +58,14 Rectangle { | |||
|
58 | 58 | size: 0.4 |
|
59 | 59 | horizontalPosition: 0.2 |
|
60 | 60 | verticalPosition: 0.3 |
|
61 | ||
|
62 | VPieModelMapper { | |
|
63 | model: chartModel | |
|
64 | labelsColumn: 0 | |
|
65 | valuesColumn: 1 | |
|
66 | } | |
|
67 | 61 | } |
|
68 | 62 | |
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
|
63 | VPieModelMapper { | |
|
64 | series: pieSeries | |
|
65 | model: chartModel | |
|
66 | labelsColumn: 0 | |
|
67 | valuesColumn: 1 | |
|
68 | } | |
|
75 | 69 |
|
|
76 | 70 | // AreaSeries { |
|
77 | 71 | // name: "area" |
@@ -59,6 +59,8 public: | |||
|
59 | 59 | qmlRegisterType<DeclarativeTableModelElement>(uri, 1, 0, "ChartModelElement"); |
|
60 | 60 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); |
|
61 | 61 | |
|
62 | qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries", | |
|
63 | QLatin1String("Trying to create uncreatable: QPieSeries.")); | |
|
62 | 64 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", |
|
63 | 65 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); |
|
64 | 66 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", |
@@ -20,31 +20,16 | |||
|
20 | 20 | |
|
21 | 21 | #include "charttablemodel.h" |
|
22 | 22 | #include <QVector> |
|
23 | #include <QTime> | |
|
24 | 23 | #include <QRect> |
|
25 | 24 | #include <QColor> |
|
26 | 25 | |
|
27 | 26 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
28 | 27 | |
|
29 | 28 | ChartTableModel::ChartTableModel(QObject *parent) : |
|
30 | QAbstractTableModel(parent) | |
|
29 | QAbstractTableModel(parent), | |
|
30 | m_columnCount(0), | |
|
31 | m_rowCount(0) | |
|
31 | 32 | { |
|
32 | qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); | |
|
33 | ||
|
34 | m_columnCount = 2; | |
|
35 | m_rowCount = 0; | |
|
36 | ||
|
37 | // m_data | |
|
38 | for (int i = 0; i < m_rowCount; i++) { | |
|
39 | QVector<QVariant>* dataVec = new QVector<QVariant>(m_columnCount); | |
|
40 | for (int k = 0; k < dataVec->size(); k++) { | |
|
41 | if (k%2 == 0) | |
|
42 | dataVec->replace(k, i * 50 + qrand()%20); | |
|
43 | else | |
|
44 | dataVec->replace(k, qrand()%100); | |
|
45 | } | |
|
46 | m_data.append(dataVec); | |
|
47 | } | |
|
48 | 33 | } |
|
49 | 34 | |
|
50 | 35 | int ChartTableModel::rowCount(const QModelIndex & parent) const |
General Comments 0
You need to be logged in to leave comments.
Login now