Results 1 to 2 of 2

Thread: QGraphicsItem::update(); vs scene()->update();

  1. #1
    Join Date
    Apr 2011
    Posts
    6
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QGraphicsItem::update(); vs scene()->update();

    Hi,

    I'm trying to make an editor based on the diagramscene example (http://qt-project.org/doc/qt-4.8/gra...gramscene.html). I have a very similar arrow-updating technique as shown in the tutorial. However, I encountered problems while trying to update the arrow shape when the source/target item geometry changes. Here is the function that gets called
    Qt Code:
    1. void ArcItem::geometryChanged()
    2. {
    3. computePath();
    4. computePolygon();
    5. computeShape();
    6. update();
    7. }
    To copy to clipboard, switch view to plain text mode 
    The arrow has a bit more complex shape which gets recomputed in the first three functions based on new positions. However, eventhough update() is called (and shape() is not isEmpty(), which I checked), sometimes, when moving the target graphicsItem arround for a while, the paint() method gets not called and the arrow simply disappears and then after some more dragging appears again. I failed to determine circumstances of these strange events and the only way I found to mage the arrows repaint correctly was to call scene()->update() which compromises performance greatly. The whole project is here https://github.com/LordNavro/CPNSimulator, the arrow graphics item is here https://github.com/LordNavro/CPNSimu...er/arcitem.cpp ...

    Thanx for any suggestions.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsItem::update(); vs scene()->update();

    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    Lord_Navro (25th April 2013)

Similar Threads

  1. Performance of scene(QGraphicsScene) with update();
    By mukunda in forum Qt Programming
    Replies: 4
    Last Post: 14th January 2011, 12:21
  2. Update scene after moving QGraphicsItem
    By rogerholmes in forum Newbie
    Replies: 1
    Last Post: 19th January 2010, 05:08
  3. QGraphicsItem does not update
    By zgulser in forum Qt Programming
    Replies: 1
    Last Post: 5th February 2009, 14:44
  4. How to update scene after removing items
    By nileshsince1980 in forum Qt Programming
    Replies: 4
    Last Post: 20th September 2007, 09:56
  5. How to find out scene update time
    By nileshsince1980 in forum Qt Programming
    Replies: 5
    Last Post: 20th September 2007, 09:46

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.