@@ -58,20 +58,14 Rectangle { | |||||
58 | size: 0.4 |
|
58 | size: 0.4 | |
59 | horizontalPosition: 0.2 |
|
59 | horizontalPosition: 0.2 | |
60 | verticalPosition: 0.3 |
|
60 | verticalPosition: 0.3 | |
61 |
|
||||
62 | VPieModelMapper { |
|
|||
63 | model: chartModel |
|
|||
64 | labelsColumn: 0 |
|
|||
65 | valuesColumn: 1 |
|
|||
66 | } |
|
|||
67 | } |
|
61 | } | |
68 |
|
62 | |||
69 |
|
|
63 | VPieModelMapper { | |
70 |
|
|
64 | series: pieSeries | |
71 |
|
|
65 | model: chartModel | |
72 |
|
|
66 | labelsColumn: 0 | |
73 |
|
|
67 | valuesColumn: 1 | |
74 |
|
|
68 | } | |
75 |
|
|
69 | ||
76 | // AreaSeries { |
|
70 | // AreaSeries { | |
77 | // name: "area" |
|
71 | // name: "area" |
@@ -59,6 +59,8 public: | |||||
59 | qmlRegisterType<DeclarativeTableModelElement>(uri, 1, 0, "ChartModelElement"); |
|
59 | qmlRegisterType<DeclarativeTableModelElement>(uri, 1, 0, "ChartModelElement"); | |
60 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); |
|
60 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); | |
61 |
|
61 | |||
|
62 | qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries", | |||
|
63 | QLatin1String("Trying to create uncreatable: QPieSeries.")); | |||
62 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", |
|
64 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", | |
63 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); |
|
65 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); | |
64 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", |
|
66 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", |
@@ -20,31 +20,16 | |||||
20 |
|
20 | |||
21 | #include "charttablemodel.h" |
|
21 | #include "charttablemodel.h" | |
22 | #include <QVector> |
|
22 | #include <QVector> | |
23 | #include <QTime> |
|
|||
24 | #include <QRect> |
|
23 | #include <QRect> | |
25 | #include <QColor> |
|
24 | #include <QColor> | |
26 |
|
25 | |||
27 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
26 | QTCOMMERCIALCHART_USE_NAMESPACE | |
28 |
|
27 | |||
29 | ChartTableModel::ChartTableModel(QObject *parent) : |
|
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 | int ChartTableModel::rowCount(const QModelIndex & parent) const |
|
35 | int ChartTableModel::rowCount(const QModelIndex & parent) const |
General Comments 0
You need to be logged in to leave comments.
Login now