void MainWindow::paintEvent(QPaintEvent *w)
{
QPainter p(this);
p.setPen(QPen(Qt::red,10));
QPointF pt(19,19);
QPointF pts[10];
int t=QTime::currentTime().second();
qsrand(t);
for(int i=0;i<10;i++)
{
pt.setX(qrand()%200);
pt.setY(qrand()%300);
pts[i]=pt;
}
p.drawPolyline(pts,10);
}
环境 Qt4.8.4 in windows vs2010