Easy yes/no QSortFilterProxyModel question...
For you QSortFilterProxyModel experts out there -- if I've created a proxy model between a QSqlTableModel and my view, would I add new rows to the proxy model or the underlying table model? I'm in the process of converting my code to the proxy, so I'm still adding data to the table model, and it works, but I wasn't sure if that's by accident...
Thanks!
scott
Re: Easy yes/no QSortFilterProxyModel question...
It doesn't matter, both should work. Provided that the proxy dynamically adjusts to the underlying model.
Re: Easy yes/no QSortFilterProxyModel question...
Good to know...I was getting some index errors earlier in another function I was using but the data was being saved to the DB okay...
After I add a row to a SQL model I check the index on the model and it was pointing to the newly added row, but after I'd set the current index on my tableview to this row, the tableview still showed it's index to be wherever I might have previously clicked on the tableview before adding my new row...I wasn't expecting that...I'd like it to be pointing to my new row but I'll work on that...
thanks!
scott
Re: Easy yes/no QSortFilterProxyModel question...
Figured it out -- after adding a row to my underlying model, I attempted to set the current index on my tableview to the index of the model, but *instead* I needed to set it to the index of the proxy model.
This is what I had been doing
Code:
flowpathmodel->insertRow(row);
fp_index = flowpathmodel->index (row, 0);
ui->FlowpathTV->setCurrentIndex (fp_index);
When I should be doing this
Code:
flowpathmodel->insertRow(row);
proxyindex = flowpathproxy->index (row, 0);
ui->FlowpathTV->setCurrentIndex (proxyindex);
When I'd inserted a new row I had expected the selection to remain with my new row, and it did with the model but not the proxy model, and now you can see why...I need to not mix and match using the underlying model with the proxy model -- one or the other, but that's the next step
scott