##// END OF EJS Templates
Adds stream operator to qlinechart
Michal Klocek -
r372:22dd70553931
parent child
Show More
@@ -11,7 +11,7
11
11
12 \snippet ../example/linechart/main.cpp 1
12 \snippet ../example/linechart/main.cpp 1
13
13
14 We add data to be shown to both series.
14 We add data to be shown to both series. We can use add() member function or use stream operator.
15
15
16 \snippet ../example/linechart/main.cpp 2
16 \snippet ../example/linechart/main.cpp 2
17
17
@@ -31,11 +31,7 int main(int argc, char *argv[])
31 series0->add(7, 4);
31 series0->add(7, 4);
32 series0->add(10,5);
32 series0->add(10,5);
33
33
34 series1->add(1, 1);
34 *series1 << QPointF(1, 1) << QPointF(3, 3) << QPointF(7, 6) << QPointF(8, 3) << QPointF(10,2);
35 series1->add(3, 3);
36 series1->add(7, 6);
37 series1->add(8, 3);
38 series1->add(10,2);
39 //![2]
35 //![2]
40 //![3]
36 //![3]
41 QMainWindow window;
37 QMainWindow window;
@@ -68,6 +68,7 QLineSeries::~QLineSeries()
68 */
68 */
69 void QLineSeries::add(qreal x,qreal y)
69 void QLineSeries::add(qreal x,qreal y)
70 {
70 {
71 Q_ASSERT(m_x.size() == m_y.size());
71 m_x<<x;
72 m_x<<x;
72 m_y<<y;
73 m_y<<y;
73 }
74 }
@@ -185,6 +186,17 QDebug operator<< (QDebug debug, const QLineSeries series)
185 return debug.space();
186 return debug.space();
186 }
187 }
187
188
189 /*!
190 Stream operator for adding a data \a point to the series.
191 \sa add()
192 */
193
194 QLineSeries& QLineSeries::operator<< (const QPointF &point)
195 {
196 add(point);
197 return *this;
198 }
199
188
200
189 #include "moc_qlineseries.cpp"
201 #include "moc_qlineseries.cpp"
190
202
@@ -35,8 +35,11 public: // from QChartSeries
35 int count() const;
35 int count() const;
36 qreal x(int pos) const;
36 qreal x(int pos) const;
37 qreal y(int pos) const;
37 qreal y(int pos) const;
38
39 QLineSeries& operator << (const QPointF &point);
38 friend QDebug operator<< (QDebug d, const QLineSeries series);
40 friend QDebug operator<< (QDebug d, const QLineSeries series);
39
41
42
40 signals:
43 signals:
41 void changed(int index);
44 void changed(int index);
42
45
General Comments 0
You need to be logged in to leave comments. Login now