Results 1 to 5 of 5

Thread: Threaded refreshing of a TreeView with custom model

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2009
    Posts
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Threaded refreshing of a TreeView with custom model

    I somehow clicked on the wrong section. Could someone please move this thread to qt Programming?

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    6
    Thanked 163 Times in 151 Posts

    Default Re: Threaded refreshing of a TreeView with custom model

    I suggest you let your second thread aggregate the data in some struct and, once finished, update your model in one go using that struct. That way you avoid both the view accessing a partially updated model and have just one "update".

    Also note that the model must only be updated from the gui thread.

  3. #3
    Join Date
    Aug 2009
    Posts
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Threaded refreshing of a TreeView with custom model

    I suggest you let your second thread aggregate the data in some struct and, once finished, update your model in one go using that struct. That way you avoid both the view accessing a partially updated model and have just one "update".
    As you may think that's surely something I thought about earlier and it's a very complicated go. I will have a look again but I hoped for different solutions.

    Also note that the model must only be updated from the gui thread.
    I know the implementation works but most times it crashes because of the written reason.

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

    Default Re: Threaded refreshing of a TreeView with custom model

    You should use the concept of snapshots - snapshot (copy) the current data at the same time blocking user changes to the model (if applicable), rearrange the copied model data in the other thread and when you're done, attach the data back to the main root of the model.
    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.


Similar Threads

  1. Replies: 12
    Last Post: 5th July 2009, 16:03
  2. Custom Model Advice Requested
    By mclark in forum Qt Programming
    Replies: 3
    Last Post: 18th September 2008, 16:26
  3. Custom proxy model issue
    By Khal Drogo in forum Qt Programming
    Replies: 13
    Last Post: 30th November 2007, 12:41
  4. Treeview and custom model
    By steg90 in forum Qt Programming
    Replies: 8
    Last Post: 15th May 2007, 13:54
  5. TreeView custom model
    By steg90 in forum Newbie
    Replies: 1
    Last Post: 9th May 2007, 10:06

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.