I have a source QStandardItemModel in which I have stored data for an object. Its first column has QDateTime values (modelTable->setData(modelTable->index(i, 2, QModelIndex()), timedate).
I want to create a new model for a QTableView by copying modelTable data into modelChart model, but I also want to have the QDateTime variable displayed in different format, e.g. ISO or localized.

How can I do this? I haven't found the method for this.
I played with DisplayRole, but didn't help.

Qt Code:
  1. for (int i=0; i<modelTable->rowCount(); i++)
  2. {
  3. modelChart->setItem(i, 0, new QStandardItem());
  4. modelChart->setData(modelChart->index(i, 0, QModelIndex()), modelTable->item(i, 2)->data(Qt::EditRole));
  5. modelChart->setData(modelChart->index(i, 0, QModelIndex()), modelTable->item(i, 2)->data(Qt::EditRole), Qt::DisplayRole);
  6. modelChart->setItem(i, 1, new QStandardItem(modelTable->item(i, 3)->text()));
  7. modelChart->setData(modelChart->index(i, 1, QModelIndex()),QColor(r, g, b),Qt::DecorationRole);
  8. }
To copy to clipboard, switch view to plain text mode 

Thanks in advance!