But idea is that i can see it in Widget as i draw them.. In Real i will need much more polygons, Like 1 million..
So simply create a method to update the data periodically and display it in paintEvent, pretty much something like you already have, but with "generate()" moved to AdvanceState. AdvanceState() should represent a single step in your calculations, used to update the data. Using a timer for this task seems reasonable.
If you want to limit the number of steps in your "simulation" use a member variable
#include "widget.h"
#include "ui_widget.h"
#include "polygonpoints.h"
ui(new Ui::Widget)
{
ui->setupUi(this);
this->setAttribute(Qt::WA_NoSystemBackground,true);
this->stepsToDo = 10000;
connect(timer, SIGNAL(timeout()), this, SLOT(AdvanceState()));
timer->start(1);
}
Widget::~Widget()
{
delete ui;
}
void Widget::AdvanceState(){
if(this->stepsToDo){
// generate new polygon or do whatever is required for a single step
--this->stepsToDo;
update(); // update requests will be scheduled, this is not an immediate repaint
} else{
this->timer->stop();
}
}
{
painter.
setRenderHint(QPainter::Antialiasing,
true);
// present the data generated in AdvanceStep()
}
#include "widget.h"
#include "ui_widget.h"
#include "polygonpoints.h"
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
this->setAttribute(Qt::WA_NoSystemBackground,true);
this->stepsToDo = 10000;
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(AdvanceState()));
timer->start(1);
}
Widget::~Widget()
{
delete ui;
}
void Widget::AdvanceState(){
if(this->stepsToDo){
// generate new polygon or do whatever is required for a single step
--this->stepsToDo;
update(); // update requests will be scheduled, this is not an immediate repaint
} else{
this->timer->stop();
}
}
void Widget::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true);
// present the data generated in AdvanceStep()
}
To copy to clipboard, switch view to plain text mode
Btw. human eye can process around 10 separate images per second if I remember correctly, you can't even notice if you try to display millions of different polygons in a short time.
Bookmarks