Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Qtableview + proxy model + sqltablemodel problem getting correct data
rfringuello89 last edited by
Hi, I'm trying to get the value from the selected cell of a QTableView.
The table has a QSqlTableModel and a QSortFilterProxyModel.
If I use the signal doubleClicked(const QModelIndex &index) (it is a tableView signal), it works as expected because I use the correct index of the row.
The problems starts when I use a simple push button to get the data from the selected cell. In fact, if the rows are sorted clicking on the header, even if the row order is changed I continue to get same row and column number and so the data is incorrect.
here some code from the on_pushButton_clicked() signal:
QModelIndexList list = ui->tableView->selectionModel()->selectedIndexes();
QModelIndex index = filterProxyModel->mapToSource(list.at(0));
bool data = ui->tableView->model()->data(ui->tableView->model()->index(index.row(),4)).toBool();
I think I should take the data using the proxy model, but I can't find the correct syntax.
Help me please!