
Originally Posted by
rickysts
I want a delay of 0.5 seconds before drawing each point, hence the timer. Not sure how this'd work out if I had the list of all 200 points in an array... code snippet anyone?
QPoint pt
(qRand
()%width
(), qRand
()%height
());
points << pt; // assuming "points" is a QList<QPoint> class member
update();
}
pe.setWidth(2);
p.setPen(pe);
foreach
(const QPoint &pt, points
){ p.drawPoint(pt);
}
}
void X::timerEvent(QTimerEvent *te){
QPoint pt(qRand()%width(), qRand()%height());
points << pt; // assuming "points" is a QList<QPoint> class member
update();
}
void X::paintEvent(QPaintEvent *pe){
QPainter p(this);
QPen pe = p.pen();
pe.setWidth(2);
p.setPen(pe);
foreach(const QPoint &pt, points){
p.drawPoint(pt);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks