[Qt-interest] How to make QTableModeView's view content update with it's Mode?

Kermit Mei kermit.mei at gmail.com
Mon Mar 2 09:38:44 CET 2009


Hello, I defined my TasksMode which inherited from  QAbstractTableModel.
And the data(..) method defined like this:


QVariant TaskModel::data(const QModelIndex &index, int role) const
{
  if(!index.isValid())
    return QVariant();
  if(role == Qt::DisplayRole) {
    return 
taskInfo.value(freeRecite::manager.getActiveTasks().at(index.row()))
      .at(index.column());
  }
  return QVariant();
}

But, When I update the TaskModel (modify taskInfo), the tableView can't
show the new Item, but just delete the items which has been deleted from
taskInfo.  Why?  What's wrong with my code?

Thanks!




More information about the Qt-interest-old mailing list