Hi Qt lovers,
I am still in the learning phase of Model/View...

I have a class derived from QAbstractTableModel where I would add a QString to a specific cell at a specific time.

Internally the data of the model is stored in a QVector called m_reports but additionally I need to store some data that I need to retrieve from the MainWindow in a doubleclick event.

I though that setData is the correct function for that but I can't get it to work and I don't understand why.

Below the function that feed the model data

Qt Code:
  1. void SelectedListModel::appendReport(const QMultiMap<QString, QString> &report)
  2. {
  3. int row = m_reports.count();
  4. beginInsertRows(QModelIndex(), row, row);
  5. QString xmlFile = report.value("xmlFilePath");
  6. qDebug() << xmlFile; // xmlFile contains right value
  7. setData(index(row, 0), QVariant(xmlFile), Qt::UserRole + 1); // <-- this does not work, no data is written
  8. m_reports.append(report);
  9. endInsertRows();
  10. }
To copy to clipboard, switch view to plain text mode 

In my MainWindow class, I catch the double-clicked event over the table view and I would get the value written with setData

?
Qt Code:
  1. connect(ui->selectedItemsView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(showConfigureDialog(const QModelIndex &)));
To copy to clipboard, switch view to plain text mode 

And the relative slot from where I would get the value I need to process

Qt Code:
  1. void MainWindow::showConfigureDialog(const QModelIndex &index)
  2. {
  3. if (index.column() == 1)
  4. {
  5. return;
  6. }
  7.  
  8. const QAbstractItemModel *model = index.model();
  9. QString xmlFilePath = model->data(model->index(index.row(), 0), Qt::UserRole+1).toString();
  10. qDebug() << "Cell Value: " << xmlFilePath; // This gives an empty output
  11. }
To copy to clipboard, switch view to plain text mode 

I can not understand what can be the problem.
I hope to get some help.

Franco