##// END OF EJS Templates
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.

File last commit:

r203:7350e0387b3f
r203:7350e0387b3f
Show More
multichartwidget.cpp
35 lines | 1.0 KiB | text/x-c | CppLexer
Tero Ahola
Added example with multiple chart views
r198 #include "multichartwidget.h"
#include <QVBoxLayout>
#include <qchartglobal.h>
#include <qchartview.h>
#include <qscatterseries.h>
#include <qpieseries.h>
QTCOMMERCIALCHART_USE_NAMESPACE
MultiChartWidget::MultiChartWidget(QWidget *parent) :
QWidget(parent)
{
QVBoxLayout *l = new QVBoxLayout(this);
// Create chart 1 and add a simple pie series onto it
QChartView *chartView1 = new QChartView();
l->addWidget(chartView1);
QPieSeries *pie = new QPieSeries();
Jani Honkonen
Refactor pie (again). QPieSlice's now emit signals and no id's anymore. Just pointers in the interface.
r203 pie->add(1.1, "label1");
pie->add(1.2, "label2");
Tero Ahola
Added example with multiple chart views
r198 chartView1->addSeries(pie);
// Create chart 2 and add a simple scatter series onto it
QChartView *chartView2 = new QChartView();
l->addWidget(chartView2);
QScatterSeries *scatter = new QScatterSeries();
*scatter << QPointF(0.5, 5.0)
<< QPointF(1.0, 4.5)
<< QPointF(1.0, 5.5)
<< QPointF(1.5, 5.0)
<< QPointF(2.0, 4.5)
<< QPointF(2.0, 5.5)
<< QPointF(2.5, 5.0);
chartView2->addSeries(scatter);
}