#include <QtGui>
#include <QApplication>
#include "nightcharts.h"
{
Q_OBJECT
public:
explicit Dialog
(QWidget *parent
= 0) , index(0)
{
this->setMinimumSize(800, 250);
startTimer(1000);
}
protected:
{
Q_UNUSED(event);
addGraphs(&painter, A[index], B[index], C[index]);
}
private:
static const int A[10];
static const int B[10];
static const int C[10];
int index;
void addGraphs
(QPainter *qp,
int i,
int j,
int k
) {
Nightcharts chart1;
chart1.setShadows(false);
chart1.setType(Nightcharts::Pie);
chart1.setLegendType(Nightcharts::Vertical);
chart1.setCords(50, 50, 80, 80);
chart1.
addPiece("Item1",
QColor(200,
10,
50), i
);
chart1.addPiece("Item2", Qt::green, j);
chart1.addPiece("Item3", Qt::cyan, k);
chart1.draw(qp);
chart1.drawLegend(qp);
Nightcharts chart2;
chart2.setShadows(false);
chart2.setType(Nightcharts::Pie);
chart2.setLegendType(Nightcharts::Vertical);
chart2.setCords(300, 50, 80, 80);
chart2.addPiece("Item2",Qt::green, j);
chart2.addPiece("Item3",Qt::cyan,k);
chart2.addPiece("Item4",Qt::yellow,i);
chart2.draw(qp);
chart2.drawLegend(qp);
Nightcharts chart3;
chart3.setShadows(false);
chart3.setType(Nightcharts::Pie);
chart3.setLegendType(Nightcharts::Vertical);
chart3.setCords(550, 50, 80, 80);
chart3.
addPiece("Item1",
QColor(200,
10,
50), k
);
chart3.addPiece("Item3",Qt::cyan, i);
chart3.addPiece("Item4",Qt::yellow, j);
chart3.draw(qp);
chart3.drawLegend(qp);
}
{
index++;
index = index % 10;
this->update();
}
};
const int Dialog::A[] = { 10, 20, 30, 40, 50, 60, 70, 70, 50, 70 };
const int Dialog::B[] = { 20, 30, 40, 50, 40, 30, 20, 10, 20, 30 };
const int Dialog::C[] = { 70, 50, 30, 10, 10, 10, 10, 20, 30, 40 };
int main(int argc, char *argv[])
{
Dialog dialog;
dialog.exec();
return a.exec();
}
#include "main.moc"
#include <QtGui>
#include <QApplication>
#include "nightcharts.h"
class Dialog : public QDialog
{
Q_OBJECT
public:
explicit Dialog(QWidget *parent = 0)
: QDialog(parent)
, index(0)
{
this->setMinimumSize(800, 250);
startTimer(1000);
}
protected:
void paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter painter(this);
addGraphs(&painter, A[index], B[index], C[index]);
}
private:
static const int A[10];
static const int B[10];
static const int C[10];
int index;
void addGraphs(QPainter *qp, int i, int j, int k)
{
Nightcharts chart1;
chart1.setShadows(false);
chart1.setType(Nightcharts::Pie);
chart1.setLegendType(Nightcharts::Vertical);
chart1.setCords(50, 50, 80, 80);
chart1.addPiece("Item1", QColor(200,10,50), i);
chart1.addPiece("Item2", Qt::green, j);
chart1.addPiece("Item3", Qt::cyan, k);
chart1.draw(qp);
chart1.drawLegend(qp);
Nightcharts chart2;
chart2.setShadows(false);
chart2.setType(Nightcharts::Pie);
chart2.setLegendType(Nightcharts::Vertical);
chart2.setCords(300, 50, 80, 80);
chart2.addPiece("Item2",Qt::green, j);
chart2.addPiece("Item3",Qt::cyan,k);
chart2.addPiece("Item4",Qt::yellow,i);
chart2.draw(qp);
chart2.drawLegend(qp);
Nightcharts chart3;
chart3.setShadows(false);
chart3.setType(Nightcharts::Pie);
chart3.setLegendType(Nightcharts::Vertical);
chart3.setCords(550, 50, 80, 80);
chart3.addPiece("Item1",QColor(200,10,50), k);
chart3.addPiece("Item3",Qt::cyan, i);
chart3.addPiece("Item4",Qt::yellow, j);
chart3.draw(qp);
chart3.drawLegend(qp);
}
void timerEvent(QTimerEvent *)
{
index++;
index = index % 10;
this->update();
}
};
const int Dialog::A[] = { 10, 20, 30, 40, 50, 60, 70, 70, 50, 70 };
const int Dialog::B[] = { 20, 30, 40, 50, 40, 30, 20, 10, 20, 30 };
const int Dialog::C[] = { 70, 50, 30, 10, 10, 10, 10, 20, 30, 40 };
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Dialog dialog;
dialog.exec();
return a.exec();
}
#include "main.moc"
To copy to clipboard, switch view to plain text mode
Bookmarks