Results 1 to 4 of 4

Thread: QGraphicsView:: PaintEvent(event) function slow on Windows XP + QT 4.5.1

  1. #1
    Join Date
    Sep 2007
    Location
    Pune, India
    Posts
    60
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QGraphicsView:: PaintEvent(event) function slow on Windows XP + QT 4.5.1

    Hello All,

    I have created application on Windows/Linux using QT 4.5.1 (Open Source). I have used QGraphicsView/Scene architecture to display Graphics items (rectangles etc).

    I have implemented zoom selection functionaliy. i.e. on Mouse selection, the zoom in the selected area using QGraphicsView::fitInView() function.

    My code works fine on Linux but on Windows XP it hangs/slows down after 2 consecutive zoom in operations.
    Please tell me what could be the cause ?? Or any clue.

    Following is the functions from my code,

    void MyGraphicsView:: PaintEvent(QPaintEvent * event)
    {
    QPaintEvent *newEvent = new QPaintEvent(event->region().boundingRect());
    QGraphicsView:: PaintEvent(event);
    delete newEvent;
    }

    void MyGraphicsView::mouseReleaseEvent(QMouseEvent *event)
    {
    QPainterPath path = scene()->selectionArea();
    scene()->clearSelection();
    fitInView(path.boundingRect(), Qt::KeepAspectRatio);
    QGraphicsView::mouseReleaseEvent(event);
    }

    Some observations :
    1. I have notices that same code works fine on Windows for QT 4.3.1 but not with QT
    4.5.1. I have also checked the updations/changes of in 4.5.1 version but not able to
    find much info. But in 4.5.0, QGraphicsView::fitInView() function has been improved for
    very small viewport. (see the link http://qt.nokia.com/developer/changes/changes-4.5.0

    2. I have obersred after some debugging that QGraphicsView:: PaintEvent(event) function is taking too much time to paint the view after 2/3 consecutive zoom-in operations.

    Can anybody tell me why QGraphicsView:: PaintEvent(event) function is taking too much time.

    Thanks in advance.
    Nilesh

  2. #2
    Join Date
    Sep 2009
    Posts
    140
    Thanks
    4
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsView:: PaintEvent(event) function slow on Windows XP + QT 4.5.1

    I haven't the solution of your problem but I note 2 points :
    • What are you overloading the paintEvent for? The default might be sufficient, I think.
    • Defining a the zoomed rect from selected items is quite weird. If items are not selectable, you can't zoom in!

  3. #3
    Join Date
    Sep 2007
    Location
    Pune, India
    Posts
    60
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsView:: PaintEvent(event) function slow on Windows XP + QT 4.5.1

    Quote Originally Posted by scascio View Post
    I haven't the solution of your problem but I note 2 points :
    • What are you overloading the paintEvent for? The default might be sufficient, I think.
    • Defining a the zoomed rect from selected items is quite weird. If items are not selectable, you can't zoom in!
    thanks for reply...

    What are you overloading the paintEvent for? The default might be sufficient, I think.
    >> I have overloaded paintEvent(..) to increse the performance.

    Defining a the zoomed rect from selected items is quite weird. If items are not selectable, you can't zoom in!

    >> What do yuo mean by this ?? I didnt get you.All items are selectable in my application.

  4. #4
    Join Date
    Sep 2009
    Posts
    140
    Thanks
    4
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsView:: PaintEvent(event) function slow on Windows XP + QT 4.5.1

    Appart the allocation and deallocation that consume time, are you sure you are creating an paintEvent with a smaller rect?
    event->region().boundingRect() is not equal to event->rect() ? In that case, you are just copying the event, aren't you?

    I mean that performing zoom might be independant from selected objects. You can manage a QRubberBand member updated with mousePressEvent, mousePressMove, and perform your zoom in mousePressRelease.

    You may concentrate on how item are painted.
    If you have custom items or pixmaps, zooming might be time consuming since they are scaled. You can overload the QGraphicsItem::paint method to save time.

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. Regading Driver to connect Postgresql Database
    By dummystories in forum Installation and Deployment
    Replies: 38
    Last Post: 12th March 2009, 07:19
  3. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  4. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  5. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.