rickysts
14th April 2008, 15:39
Folks,
A trivial question. How do I draw stuff on the canvas without erasing the old stuff?
Consider this code snippet for drawing 200 random points on a 320x240 window:
void dlg::timerEvent(QTimerEvent *event)
{
if (count < 200) {
count=count+1;
x = rand() % 320;
y = rand() % 240;
update();
} else {
timer.stop();
}
}
void dlg::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.drawPoint(x,y);
update();
}
It'd draw one point, erase the screen and then draw the next point. I don't want that. I want the old points to stay. How do I do this?
Thanks,
Ricky.
A trivial question. How do I draw stuff on the canvas without erasing the old stuff?
Consider this code snippet for drawing 200 random points on a 320x240 window:
void dlg::timerEvent(QTimerEvent *event)
{
if (count < 200) {
count=count+1;
x = rand() % 320;
y = rand() % 240;
update();
} else {
timer.stop();
}
}
void dlg::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.drawPoint(x,y);
update();
}
It'd draw one point, erase the screen and then draw the next point. I don't want that. I want the old points to stay. How do I do this?
Thanks,
Ricky.