Results 1 to 1 of 1

Thread: Single Item update in QGraphicsView

  1. #1
    Join Date
    Mar 2010
    Posts
    10
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Single Item update in QGraphicsView

    Hi,

    Is it possible to have a QGraphicsView update a single graphical item?

    I have an application which uses the following hierarchy (roughly):

    QAbstractItemModel <- ConcreteModel

    QGraphicsView <- ConcreteGraphicsView

    QObject, QGraphicsPolygonItem, QGraphicsLayoutItem <- ConcreteGraphicsItem

    ConcreteGraphicsView contains a QGraphicsScene object and also has access to the QAbstractItemModel.

    The application works fine in the sense I can get all of the graphics items laid out and displayed.

    Now I would like to change one of the item data and have the view automatically update just the item I changed (not the whole view). I can have the whole view change by explicitly clearing the scene and rebuilding it by iterating through the model within the view object, but apart from being an overkill it resets the layout of the items which may have been manually re-arranged through the view.

    I've read about delegates in the context of the QAbstractItemView and the fact QAbstractItemView implements the observer pattern, but I can't figure out how I can apply these concepts in my application given I'm using a QGraphicsView.

    As an experiment I modified the model class to fire a QTimer connected to a slot which emitted a layoutChanged() signal, but I never see the view call the model data() method to retrieve anything.

    Thanks in advance for any help.
    Last edited by oberlus; 27th August 2010 at 12:30.

Similar Threads

  1. Replies: 2
    Last Post: 9th August 2010, 17:53
  2. Replies: 4
    Last Post: 10th June 2010, 21:25
  3. QGraphicsView to fast update images
    By ^NyAw^ in forum Qt Programming
    Replies: 12
    Last Post: 8th May 2009, 22:17
  4. QGraphicsView won't update until resize
    By stevel in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2009, 21:45
  5. Changing font color for a single item in a QTreeView
    By Doug Broadwell in forum Qt Programming
    Replies: 1
    Last Post: 3rd November 2007, 19:14

Tags for this Thread

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.