##// END OF EJS Templates
Fixed build error caused by QSeries name change
Fixed build error caused by QSeries name change

File last commit:

r655:7ed6749a4b0d
r733:a8e3d9a5ee37
Show More
tablewidget.cpp
249 lines | 8.2 KiB | text/x-c | CppLexer
Marek Rosa
Table model data example
r519 #include "tablewidget.h"
#include <QGridLayout>
#include <QTableView>
#include <QStyledItemDelegate>
#include "qlineseries.h"
#include "qsplineseries.h"
Marek Rosa
Added support for adding and removing data with model. Updated the example
r545 #include "qscatterseries.h"
Marek Rosa
Table model data example
r519 #include "customtablemodel.h"
#include "qpieseries.h"
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 #include "qareaseries.h"
#include "qbarseries.h"
Marek Rosa
Added support for adding and removing data with model. Updated the example
r545 #include <QPushButton>
#include <QRadioButton>
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 #include <QTime>
Marek Rosa
Table model data example
r519
TableWidget::TableWidget(QWidget *parent)
: QWidget(parent)
{
Marek Rosa
Model data example updated
r546 setGeometry(100, 100, 1000, 600);
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
Marek Rosa
Table model data example
r519 // create simple model for storing data
// user's table data model
Marek Rosa
Added support for adding and removing data with model. Updated the example
r545 m_model = new CustomTableModel;
tableView = new QTableView;
tableView->setModel(m_model);
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 tableView->setMinimumHeight(240);
// tableView->setMinimumSize(340, 480);
Marek Rosa
Table model data example
r519 // tableView->setItemDelegate(new QStyledItemDelegate);
Marek Rosa
Model data example updated
r546 chartView = new QChartView(this);
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 chartView->setRenderHint(QPainter::Antialiasing);
Marek Rosa
Table model data example
r519 chartView->setMinimumSize(640, 480);
// create
// QLineSeries* series = new QLineSeries;
Marek Rosa
Added support for adding and removing data with model. Updated the example
r545 // QSplineSeries* series = new QSplineSeries;
// QScatterSeries* series = new QScatterSeries;
// series->setModel(m_model);
// series->setModelMapping(0,1, Qt::Vertical);
Marek Rosa
Table model data example
r519
// QPieSeries* pieSeries = new QPieSeries;
// pieSeries->setModel(model);
// pieSeries
Marek Rosa
Added support for adding and removing data with model. Updated the example
r545 // chartView->addSeries(series);
// add, remove data buttons
Marek Rosa
Model data example updated
r546 QPushButton* addRowAboveButton = new QPushButton("Add row above");
connect(addRowAboveButton, SIGNAL(clicked()), this, SLOT(addRowAbove()));
QPushButton* addRowBelowButton = new QPushButton("Add row below");
connect(addRowBelowButton, SIGNAL(clicked()), this, SLOT(addRowBelow()));
Marek Rosa
Added support for adding and removing data with model. Updated the example
r545
QPushButton* removeRowButton = new QPushButton("Remove row");
connect(removeRowButton, SIGNAL(clicked()), this, SLOT(removeRow()));
// buttons layout
QVBoxLayout* buttonsLayout = new QVBoxLayout;
Marek Rosa
Model data example updated
r546 buttonsLayout->addWidget(addRowAboveButton);
buttonsLayout->addWidget(addRowBelowButton);
Marek Rosa
Added support for adding and removing data with model. Updated the example
r545 buttonsLayout->addWidget(removeRowButton);
buttonsLayout->addStretch();
// chart type radio buttons
lineRadioButton = new QRadioButton("Line");
splineRadioButton = new QRadioButton("Spline");
scatterRadioButton = new QRadioButton("Scatter");
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 pieRadioButton = new QRadioButton("Pie");
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 areaRadioButton = new QRadioButton("Area");
barRadioButton = new QRadioButton("Bar");
Marek Rosa
Added support for adding and removing data with model. Updated the example
r545
connect(lineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType()));
connect(splineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType()));
connect(scatterRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType()));
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 connect(pieRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType()));
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 connect(areaRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType()));
connect(barRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType()));
Marek Rosa
Added support for adding and removing data with model. Updated the example
r545 lineRadioButton->setChecked(true);
// radio buttons layout
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 QVBoxLayout* radioLayout = new QVBoxLayout;
Marek Rosa
Added support for adding and removing data with model. Updated the example
r545 radioLayout->addWidget(lineRadioButton);
radioLayout->addWidget(splineRadioButton);
radioLayout->addWidget(scatterRadioButton);
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 radioLayout->addWidget(pieRadioButton);
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 radioLayout->addWidget(areaRadioButton);
radioLayout->addWidget(barRadioButton);
radioLayout->addStretch();
Marek Rosa
Table model data example
r519
// create main layout
QGridLayout* mainLayout = new QGridLayout;
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 mainLayout->addLayout(buttonsLayout, 1, 0);
mainLayout->addLayout(radioLayout, 2, 0);
Marek Rosa
Table model data example
r519 mainLayout->addWidget(tableView, 1, 1);
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 mainLayout->addWidget(chartView, 2, 1);
Marek Rosa
Added support for adding and removing data with model. Updated the example
r545 setLayout(mainLayout);
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 lineRadioButton->setFocus();
Marek Rosa
Added support for adding and removing data with model. Updated the example
r545 }
Marek Rosa
Model data example updated
r546 void TableWidget::addRowAbove()
{
// m_model->insertRow(m_model->rowCount());
m_model->insertRow(tableView->currentIndex().row());
}
void TableWidget::addRowBelow()
Marek Rosa
Added support for adding and removing data with model. Updated the example
r545 {
// m_model->insertRow(m_model->rowCount());
m_model->insertRow(tableView->currentIndex().row() + 1);
}
void TableWidget::removeRow()
{
// m_model->removeRow(m_model->rowCount() - 1);
m_model->removeRow(tableView->currentIndex().row());
}
void TableWidget::updateChartType()
{
chartView->removeAllSeries();
if (lineRadioButton->isChecked())
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 {
// series 1
series = new QLineSeries;
series->setModel(m_model);
series->setModelMapping(0,1, Qt::Vertical);
// series->setModelMapping(0,1, Qt::Horizontal);
chartView->addSeries(series);
// series 2
series = new QLineSeries;
series->setModel(m_model);
series->setModelMapping(2,3, Qt::Vertical);
// series->setModelMapping(2,3, Qt::Horizontal);
chartView->addSeries(series);
// series 3
Marek Rosa
Added support for adding and removing data with model. Updated the example
r545 series = new QLineSeries;
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 series->setModel(m_model);
series->setModelMapping(4,5, Qt::Vertical);
// series->setModelMapping(4,5, Qt::Horizontal);
chartView->addSeries(series);
}
Marek Rosa
Added support for adding and removing data with model. Updated the example
r545 else if (splineRadioButton->isChecked())
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 {
// series 1
series = new QSplineSeries;
series->setModel(m_model);
series->setModelMapping(0,1, Qt::Vertical);
// series->setModelMapping(0,1, Qt::Horizontal);
chartView->addSeries(series);
// series 2
Marek Rosa
Added support for adding and removing data with model. Updated the example
r545 series = new QSplineSeries;
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 series->setModel(m_model);
series->setModelMapping(2,3, Qt::Vertical);
// series->setModelMapping(2,3, Qt::Horizontal);
chartView->addSeries(series);
// series 3
series = new QSplineSeries;
series->setModel(m_model);
series->setModelMapping(4,5, Qt::Vertical);
// series->setModelMapping(4,5, Qt::Horizontal);
chartView->addSeries(series);
}
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 else if (scatterRadioButton->isChecked())
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 {
// series 1
series = new QScatterSeries;
series->setModel(m_model);
series->setModelMapping(0,1, Qt::Vertical);
// series->setModelMapping(0,1, Qt::Horizontal);
chartView->addSeries(series);
// series 2
series = new QScatterSeries;
series->setModel(m_model);
series->setModelMapping(2,3, Qt::Vertical);
// series->setModelMapping(2,3, Qt::Horizontal);
chartView->addSeries(series);
// series 3
Marek Rosa
Added support for adding and removing data with model. Updated the example
r545 series = new QScatterSeries;
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 series->setModel(m_model);
series->setModelMapping(4,5, Qt::Vertical);
// series->setModelMapping(4,5, Qt::Horizontal);
chartView->addSeries(series);
}
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 else if (pieRadioButton->isChecked())
{
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 // pie 1
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 QPieSeries* pieSeries = new QPieSeries;
pieSeries->setModel(m_model);
Marek Rosa
Barchart updates on BarSet->SetValue now
r655 pieSeries->setModelMapping(0,0, Qt::Vertical);
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 pieSeries->setLabelsVisible(true);
pieSeries->setPieSize(0.4);
pieSeries->setPiePosition(0.2, 0.35);
chartView->addSeries(pieSeries);
// pie 2
pieSeries = new QPieSeries;
pieSeries->setModel(m_model);
Marek Rosa
Barchart updates on BarSet->SetValue now
r655 pieSeries->setModelMapping(1,1, Qt::Vertical);
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 pieSeries->setLabelsVisible(true);
pieSeries->setPieSize(0.4);
pieSeries->setPiePosition(0.8, 0.35);
chartView->addSeries(pieSeries);
// pie 3
pieSeries = new QPieSeries;
pieSeries->setModel(m_model);
Marek Rosa
Barchart updates on BarSet->SetValue now
r655 pieSeries->setModelMapping(2,2, Qt::Vertical);
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 pieSeries->setLabelsVisible(true);
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 pieSeries->setPieSize(0.4);
pieSeries->setPiePosition(0.5, 0.65);
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 chartView->addSeries(pieSeries);
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 }
else if (areaRadioButton->isChecked())
{
QLineSeries* upperLineSeries = new QLineSeries;
upperLineSeries->setModel(m_model);
upperLineSeries->setModelMapping(0, 1, Qt::Vertical);
QLineSeries* lowerLineSeries = new QLineSeries;
lowerLineSeries->setModel(m_model);
lowerLineSeries->setModelMapping(2, 3, Qt::Vertical);
QAreaSeries* areaSeries = new QAreaSeries(upperLineSeries, lowerLineSeries);
chartView->addSeries(areaSeries);
}
else if (barRadioButton->isChecked())
{
QBarSeries* barSeries = new QBarSeries(QStringList());
barSeries->setModel(m_model);
barSeries->setModelMapping(5, 2, 4, Qt::Vertical);
barSeries->setToolTipEnabled(true);
chartView->addSeries(barSeries);
Marek Rosa
Added data from model support to QPieSeries(modify, remove). Data from model example updated
r597 }
Marek Rosa
Added support for adding and removing data with model. Updated the example
r545
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 // series->setModel(m_model);
// series->setModelMapping(0,1, Qt::Vertical);
// chartView->addSeries(series);
Marek Rosa
Table model data example
r519 }
TableWidget::~TableWidget()
{
}