#include <QtGui>class MyClass : public QWidget{public: MyClass(){ } void paintEvent(QPaintEvent* event) { int i=0; QTime time; time.start(); for(i=0;i<100;i++){ QPainter p(this); p.setRenderHint(QPainter::Antialiasing,true); p.setPen(QPen(Qt::blue,2,Qt::SolidLine)); p.drawLine(0,0,640,480); p.end(); } qDebug()<<"paint"<< " mc = " <<time.elapsed(); }};int main(int argc, char* argv[]){ QApplication app(argc, argv); MyClass* myClass = new MyClass(); myClass->resize(640,480); myClass->show(); return app.exec();}
QTime time; time.start(); QPainter p(this); p.setRenderHint(QPainter::Antialiasing,true); p.setPen(QPen(Qt::blue,2,Qt::SolidLine)); QPainterPath path; for(int i=0;i<100;i++){ path.moveTo(0,0); path.lineTo(640,480); } p.drawPath(path); p.end(); qDebug()<< "paint"<< " mc = " <<time.elapsed();