Results 1 to 6 of 6

Thread: Updating Foreground for QGraphicsView

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    37
    Thanked 53 Times in 40 Posts

    Default Re: Updating Foreground for QGraphicsView

    Quote Originally Posted by tts80 View Post
    Only problem is that only a bounding rect region containing all graphics items in the scene is updated. Is that where the rubber band technique comes in? At the moment I simply call QGraphicsScene->update(QGraphicsScene->sceneRect()) which updates the entire scene. Not very efficient way to do things I suppose.
    Thuan Seah
    You can use QRubberBand with its parent being QGraphicsView->viewport() and then call setGeometry() appropriately while providing feedback of line being drawn. You need not update scene in that case. See QRubberBand's doc for more details.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 334 Times in 317 Posts

    Default Re: Updating Foreground for QGraphicsView

    well if u are implementing the edge as item, u need not worry about the rubber banding. what u need to do is just change the shape of the item on mouse movements.
    for this u can maintain a list of edges in contact with a node, now when the node moves, u change the shape of edges connected to it and call the update to items if necessary.
    As for the bounding rect u can return the rectangle covered by the line.
    for shape, override the shape() method... and be sure to call prepareGeometryChange() before changing the shape...

    try it, hope it will solve the prob

  3. #3
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    37
    Thanked 53 Times in 40 Posts

    Default Re: Updating Foreground for QGraphicsView

    Just one more tip for you. I guess you can use already existing QGraphicsLineItem or a class derived from it for edges which simplies a lot. You just need to call QGraphicsLineItem::setLine(QLineF line) method and no need to worry about geometry at all. Hope this helps.

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.