##// END OF EJS Templates
Model example updated
Marek Rosa -
r1292:9201aada12d2
parent child
Show More
@@ -25,7 +25,7
25 25 #include <QChart>
26 26 #include <QChartView>
27 27 #include <QLineSeries>
28 #include "qxymodelmapper.h"
28 #include <QVXYModelMapper>
29 29 #include <QHeaderView>
30 30
31 31 QTCOMMERCIALCHART_USE_NAMESPACE
@@ -52,47 +52,44 TableWidget::TableWidget(QWidget *parent)
52 52 chart->setAnimationOptions(QChart::AllAnimations);
53 53 //! [3]
54 54
55 // // series 1
56 // //! [4]
57 // QLineSeries *series = new QLineSeries;
58 // series->setModel(model);
55 // series 1
56 //! [4]
57 QLineSeries *series = new QLineSeries;
58 QVXYModelMapper *mapper = new QVXYModelMapper(this);
59 mapper->setXColumn(0);
60 mapper->setYColumn(1);
61 mapper->setSeries(series);
62 mapper->setModel(model);
63 chart->addSeries(series);
64 //! [4]
59 65
60 // QXYModelMapper *mapper = new QXYModelMapper;
61 // mapper->setMapX(0);
62 // mapper->setMapY(1);
63 // series->setModelMapper(mapper);
64 //// series->setModelMapping(0, 1, Qt::Vertical);
65 // chart->addSeries(series);
66 // //! [4]
66 //! [5]
67 // for storing color hex from the series
68 QString seriesColorHex = "#000000";
67 69
68 // //! [5]
69 // // for storing color hex from the series
70 // QString seriesColorHex = "#000000";
70 // get the color of the series and use it for showing the mapped area
71 seriesColorHex = "#" + QString::number(series->pen().color().rgb(), 16).right(6).toUpper();
72 model->addMapping(seriesColorHex, QRect(0, 0, 2, model->rowCount()));
73 //! [5]
71 74
72 // // get the color of the series and use it for showing the mapped area
73 // seriesColorHex = "#" + QString::number(series->pen().color().rgb(), 16).right(6).toUpper();
74 // model->addMapping(seriesColorHex, QRect(0, 0, 2, model->rowCount()));
75 // //! [5]
76 75
76 // series 2
77 //! [6]
78 series = new QLineSeries;
77 79
78 // // series 2
79 // //! [6]
80 // series = new QLineSeries;
81 // series->setModel(model);
80 mapper = new QVXYModelMapper(this);
81 mapper->setXColumn(2);
82 mapper->setYColumn(3);
83 mapper->setSeries(series);
84 mapper->setModel(model);
85 chart->addSeries(series);
86 //! [6]
82 87
83 // mapper = new QXYModelMapper;
84 // mapper->setMapX(2);
85 // mapper->setMapY(3);
86 // series->setModelMapper(mapper);
87 //// series->setModelMapping(2,3, Qt::Vertical);
88 // chart->addSeries(series);
89 // //! [6]
90
91 // //! [7]
92 // // get the color of the series and use it for showing the mapped area
93 // seriesColorHex = "#" + QString::number(series->pen().color().rgb(), 16).right(6).toUpper();
94 // model->addMapping(seriesColorHex, QRect(2, 0, 2, model->rowCount()));
95 // //! [7]
88 //! [7]
89 // get the color of the series and use it for showing the mapped area
90 seriesColorHex = "#" + QString::number(series->pen().color().rgb(), 16).right(6).toUpper();
91 model->addMapping(seriesColorHex, QRect(2, 0, 2, model->rowCount()));
92 //! [7]
96 93
97 94 //! [8]
98 95 QChartView *chartView = new QChartView(chart);
General Comments 0
You need to be logged in to leave comments. Login now