Results 1 to 7 of 7

Thread: QPainter::drawRect in Qt4.5 is much slower than that in Qt4.3

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2010
    Posts
    4
    Qt products
    Qt4

    Default QPainter::drawRect in Qt4.5 is much slower than that in Qt4.3

    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();
    }
    Last edited by bgcrwf; 15th April 2010 at 11:51.

Similar Threads

  1. Qt/mingw a lot slower than borland builder 6.0?
    By qt_gotcha in forum Qt Programming
    Replies: 2
    Last Post: 23rd February 2010, 12:11
  2. why Qt4 is so slower than Qt3 ?
    By xuyaojun1980 in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 11th February 2009, 18:32
  3. Which is faster, drawRect(..) Or drawPath(..) ?
    By nileshsince1980 in forum Qt Programming
    Replies: 1
    Last Post: 18th November 2008, 08:26
  4. problem about drawRect
    By vql in forum Qt Programming
    Replies: 4
    Last Post: 29th April 2008, 01:07
  5. drawRect inside paintGL()
    By mickey in forum Newbie
    Replies: 16
    Last Post: 18th April 2006, 01:12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.