Results 1 to 2 of 2

Thread: In model/view: how to make the view to be aware that the model content has changed

  1. #1
    Join Date
    Jan 2008
    Location
    Germany
    Posts
    80
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default In model/view: how to make the view to be aware that the model content has changed

    Let me take example on itemviews/simpletreemodel
    In this example the model is filled when the application starts, then the model is set for the view to present it.
    The data representedby the model is never changing.

    Now my question is the following:
    Supposing that we have a model which data is changing over the time.

    How should the model be implemented when data has to be added to it internal data holder so that the view gets informed that the data of the model has changed and by consequence adapts automatically it representation of the model ?

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: In model/view: how to make the view to be aware that the model content has change

    Check the QAbstractItemModel docs for

    dataChanged(QModelIndex, QModelIndex);
    beginInsertRows(int, int);
    endInsertRows();
    beginRemoveRows(int, int);
    endRemoveRows();

    and other functions like that.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

Similar Threads

  1. QSql Model-View: How to keep view in sync with model
    By schall_l in forum Qt Programming
    Replies: 1
    Last Post: 23rd December 2008, 00:31
  2. Replies: 1
    Last Post: 16th January 2008, 12:48
  3. Help with Model View
    By weepdoo in forum Qt Programming
    Replies: 13
    Last Post: 12th October 2007, 11:32
  4. Model-view: Creating a custom view
    By taboom in forum Qt Programming
    Replies: 5
    Last Post: 17th August 2007, 21:36
  5. Model View Help Please
    By munna in forum Newbie
    Replies: 2
    Last Post: 22nd July 2006, 19:19

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.