PDA

View Full Version : How to remove a record from a table with a composed primary key using QModelIndex ?



nagpalma
9th July 2007, 20:17
Hello,

How to remove a record from a table with a composed primary key using QModelIndex and removeRow?

In tables with simple primary key (just one column) it works fine with:


QModelIndex index = sequenceTableView->currentIndex();
if (!index.isValid())
return;
sequenceModel->removeRow(index.row());
}

but with 2 columns (with similar code) i can't delete the record and in the output window appears the message:

QSqlQuery::value: not positioned on a valid record


Any help would be appreciated.
Thanks,
Palma

nagpalma
16th July 2007, 12:19
the problem is solved, the index was returning wrong types. I was pretending to remove a row from a QSqlRelationalTableModel whose index is formed by two fields that are foreign keys, and the index was returning the names instead of the ids....

pcheng
25th June 2012, 11:54
Can you please provide some input on how you solved this problem?

Thanks,

Pericles