As title. I wrote a program to test the peformance of QPainter::drawRect.
This program draws 10 rectangles 100 times.
In Qt4.5, the elapsed time is over 1 minute.
But in Qt4.3, the elapsed time is less than 1 second.
By the way, I executed it in Linux X11.
What should I do to fix the problem in Qt4.5?
Thanks a lot.
======================================
class PainterWidget : public QWidget
{
protected:
void paintEvent(QPaintEvent *);
};
void PainterWidget :: paintEvent(QPaintEvent *)
{
// You can change the file name if you need
QBitmap pixmap("xxx.pbm");
QBrush brush(pixmap);
brush.setColor(Qt::red);
QPainter painter(this);
painter.end();
painter.begin(this);
painter.setBrush(brush);
QRect rect;
for (int j=0; j<100; j++) {
for (int i=0; i<10; i++) {
rect.setRect(i*100, 0, 100, 1000);
painter.drawRect(rect);
}
}
painter.end();
}
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
PainterWidget window;
window.resize(1000, 1000);
window.show();
return app.exec();
}
Bookmarks