PDA

View Full Version : How to make QTableView aware that a new item in the model has beed aded?



qlands
12th August 2011, 13:31
Hi,

So I have a QTableView using my model based on QAbstractTableModel. My model loads items from a file and stores them in a QList. I have a function called addItem(QString code, QString description) that appends a new item at the end of the QList..

rowCount() returns my_items.count();

I also implemented data() so it properly shows the current items in the file.

Now, what do I need to do so the view shows the new item?

Thanks,
Carlos.

MasterBLB
12th August 2011, 14:33
Implement in your model public function that calls QAbstractItemModel::reset(),then invoke it

nix
12th August 2011, 15:06
Take a look to
void QAbstractItemModel::layoutChanged (), you have to emit this signal and then the view will know and refresh itself about the change.