Results 1 to 2 of 2

Thread: Updating QTreeView when data has changed

  1. #1
    Join Date
    May 2013
    Posts
    24
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Updating QTreeView when data has changed

    Hi,

    I have made a custom model to display a tree-like data structure. When the user modify one node in the data structure the change will affect all its parents. To calculate the change the node is calling the calculate() method on its parent, the change is traversed upward in the tree. The calculation is done when the root node is reached. During calculation the setData() in the model is not used and thus dataChanged() is not emitted.

    What options do I have to solve this?

    Is there a way to create an Index from column number, row number and pointer to the node? I could use this index to emit the dataChanged signal from the nodes (maybe via the model).

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 453 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Updating QTreeView when data has changed

    Is there a way to create an Index from column number, row number and pointer to the node? I could use this index to emit the dataChanged signal from the nodes (maybe via the model).
    You need come up with a mechanism to map between the node and mode index, to help on this there is an option of creating index with some custom information in it, i.e. internal pointer or id in the index. The trick is to embedded some node/parent node information in the index while creating it.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

Similar Threads

  1. Replies: 3
    Last Post: 11th December 2012, 16:32
  2. dataChanged, isDirty -- how to tell data was changed...
    By scott_hollen in forum Qt Programming
    Replies: 7
    Last Post: 1st October 2011, 17:31
  3. Replies: 1
    Last Post: 8th June 2011, 14:13
  4. Replies: 12
    Last Post: 24th July 2010, 08:12
  5. Informing a model its data has changed
    By saknopper in forum Newbie
    Replies: 3
    Last Post: 17th January 2007, 19:58

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.