Results 1 to 10 of 10

Thread: QTableView : How to refresh the view after an update of the model ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2006
    Location
    Dresden, Germany
    Posts
    109
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    9
    Thanked 12 Times in 10 Posts

    Default Re: QTableView : How to refresh the view after an update of the model ?

    I simply set the model again in table view using setModel(). Don't know whether this is most efficient but it works...

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

    Default Re: QTableView : How to refresh the view after an update of the model ?

    Quote Originally Posted by ghorwin View Post
    I simply set the model again in table view using setModel(). Don't know whether this is most efficient but it works...
    That's the worst you can do, as all the model-view framework is then reset. It's even worse than if you would call reset() on the model - the result would be the same but without the need to reinstall the model into the view (just the data would be refetched). The proper solution is to emit layoutChanged() or dataChanged() from the model.

Similar Threads

  1. hierarchical model in a flat view
    By gniking in forum Qt Programming
    Replies: 4
    Last Post: 10th November 2009, 20:17
  2. Model - View Programming doubt.
    By munna in forum Qt Programming
    Replies: 4
    Last Post: 28th April 2006, 13:01
  3. Replies: 6
    Last Post: 20th April 2006, 10:23
  4. Model, view, resize to show all data
    By jcr in forum Qt Programming
    Replies: 2
    Last Post: 17th April 2006, 20:59
  5. Table model / view editing issue
    By Caius Aérobus in forum Qt Programming
    Replies: 9
    Last Post: 7th April 2006, 11:03

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.