I made use of QAbstractTableModel to show data retrieved through QNetworkAccessManager in a QTableView, it works well, the only issue is that if the data is changed the model doesn't "refresh" until I click on the tableview or scroll through the table.

header:
Qt Code:
  1. class ModelLClienti:public QAbstractTableModel{
  2. Q_OBJECT
  3. public:
  4. ModelLClienti(QObject *parent=0);
  5.  
  6. int rowCount(const QModelIndex &parent) const;
  7. int columnCount(const QModelIndex &parent) const;
  8. QVariant data(const QModelIndex &index, int role) const;
  9. QVariant headerData(int section, Qt::Orientation orientation, int role) const;
  10. void setLista(QList<QString> lista);
  11. private:
  12. QList<QString> listaCli;
  13. };
To copy to clipboard, switch view to plain text mode 

source:
Qt Code:
  1. ModelLClienti::ModelLClienti(QObject *parent):QAbstractTableModel(parent){
  2. }
  3.  
  4. int ModelLClienti::rowCount(const QModelIndex &parent) const{
  5. Q_UNUSED(parent);
  6. return listaCli.size()-1;
  7. }
  8. int ModelLClienti::columnCount(const QModelIndex &parent) const{
  9. Q_UNUSED(parent);
  10. return 2;
  11. }
  12. QVariant ModelLClienti::data(const QModelIndex &index, int role) const{
  13.  
  14. if (!index.isValid())
  15. return QVariant();
  16.  
  17. if (index.row() >= listaCli.size() || index.row() < 0)
  18. return QVariant();
  19.  
  20. if (role == Qt::DisplayRole) {
  21. l=listaCli.at(index.row()).split(',');
  22. if(index.column()==0)
  23. return l[0];
  24. if (index.column() == 1)
  25. return l[1].toUpper();
  26. }
  27. return QVariant();
  28. }
  29. QVariant ModelLClienti::headerData(int section, Qt::Orientation orientation, int role) const{
  30. if (role != Qt::DisplayRole)
  31. return QVariant();
  32.  
  33. if (orientation == Qt::Horizontal) {
  34. switch (section) {
  35. case 0:
  36. return tr("clientId");
  37. case 1:
  38. return tr("Client");
  39. default:
  40. return QVariant();
  41. }
  42. }
  43. return QVariant();
  44. }
  45. void ModelLClienti::setLista(QList<QString> lista){
  46. listaCli=lista;
  47. }
To copy to clipboard, switch view to plain text mode 

I need to change the data inside the model and afterwards, show in the tableview.