Results 1 to 13 of 13

Thread: How to inform a Model/TableView that some data changed?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    82
    Thanked 11 Times in 11 Posts

    Default Re: How to inform a Model/TableView that some data changed?

    Hey Mole - doesn't seem right to me that the model doesn't know about the view.
    What about: view->setModel(model)
    and from the M/V architecture doc: "Signals from the model inform the view about changes to the data held by the data source."
    What did you mean? Maybe only the view now knows about the model, but then what about that line in the doc?

  2. #2
    Join Date
    Jun 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to inform a Model/TableView that some data changed?

    Quote Originally Posted by waynew View Post
    Hey Mole - doesn't seem right to me that the model doesn't know about the view.
    What about: view->setModel(model)
    and from the M/V architecture doc: "Signals from the model inform the view about changes to the data held by the data source."
    What did you mean? Maybe only the view now knows about the model, but then what about that line in the doc?

    I think you might just be misinterpreting the documents. The way I see it (and the way MVC is supposed to work) is that models simply inform any listeners of changes. The way this is done in Qt is that models emit signals (like void rowsInserted( const QModelIndex & parent, int start, int end) or void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight) ) and views simply connect to those. At no point is the model aware that something is connected to it, nor does it need to know.

    Models are supposed to be just that, models of some underlying data structure. The whole point of MVC is keeping the model, view and controller separate from each other.

  3. #3
    Join Date
    Jul 2010
    Location
    Cairo, Egypt
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: How to inform a Model/TableView that some data changed?

    Well, I tried something and it worked fine. Each time I update my database, I set my tableview one more time

    Qt Code:
    1. model->setTable("Contacts");
    2. model->select();
    3. ui->tableView->setModel(model);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. TableView/Model Display Question
    By SixDegrees in forum Qt Programming
    Replies: 9
    Last Post: 27th August 2010, 10:06
  2. Replies: 1
    Last Post: 1st February 2010, 19:42
  3. tableview model view problem
    By skuda in forum Qt Programming
    Replies: 5
    Last Post: 3rd December 2007, 15:02
  4. getting data from tableView
    By mkarakaplan in forum Newbie
    Replies: 1
    Last Post: 7th November 2007, 10:51
  5. Informing a model its data has changed
    By saknopper in forum Newbie
    Replies: 3
    Last Post: 17th January 2007, 20:58

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
  •  
Qt is a trademark of The Qt Company.