Hello,
I have a tableview / sqlmodel.
A selection in the table can be made to rename those items with a dialog.
Renaming the items in the sql database is done by QSqlquery and afterwards the model gets a select() so the data is up to date, this works fine.
But I want to retain the selection after the select().
I am trying to do a loop with the (new because the tabel is sorted and positions can change) rownumbers and selectRow().
for (int i = 0; i < newnames.count(); i++)
table->selectRow(findSong(newnames[i]));
//findSong is code of my own to get the correct rownumber
for (int i = 0; i < newnames.count(); i++)
table->selectRow(findSong(newnames[i]));
//findSong is code of my own to get the correct rownumber
To copy to clipboard, switch view to plain text mode
But the result is that only the last row is selected allthough the table has:
setSelectionBehavior(QAbstractItemView::SelectRows );
setSelectionMode(QAbstractItemView::ExtendedSelect ion);
Why does that loop with selectRow() only select the last row and what can I do about it? I looked at QAbstractItemView::setSelection() but that one wants a rect.
Thanks
Bookmarks