PDA

View Full Version : Insert a row to a QSqlTableModel with prefilled columns



zeb
9th December 2010, 15:53
Hi,

I have a QSqlTableModel. I use Blanchette's method to insert a new row:

int row = myModel->rowCount();
myModel->insertRow(row);
QModelIndex index = myModel->index(row, 1);
myTableView->setCurrentIndex(index);
myTableView->edit(index);

I would like to fill one of the columns of myModel (which is hidden in the View) with a value (which depends on a selection on another table). Is that possible?

Thanks in advance.

I reply to myself, as I found a way:


myModel->setData(myModel->index(row,1), value);