I've class which comes from QSqlRelationalTableModel. I personally use SQLite database. And I have to change database file. I close old database file, call SetDatabaseName("road to new file") and open new database file. Now I simply call choose() for that model, however it returns false. And when I call setTable("table") and just next choose(), everything works... But title on the table is identical...

I did not find any method which enables to see one that database connection continues to be transformed.... Are you aware an easy method to see the model?


Ok. I've came back for this subject once more.

After db is transformed I must call setTable() with similar table title to reinit table model. And I didn't find an easy method how you can reinit table view, co I call

pTableView->setModel(NULL);
pTableView->setModel(model);

This creates lots of unnecessary code calls, however in other situation table view doesn't learn about alterations in table model (for instance posts count).

I didn't find an easy method to reinitialize QSqlTableModel and QTableView. Ideas?

Which was my fault :( With assistance of sources I discovered by which cases choose() returns false. And something fieldname within the table of my new database misses one letter:( So, QSqlQuery with choose came back error. setTable call updates fieldnames on the table, so choose returns true.