PDA

View Full Version : refreshing QSqlRelationalDelegate data



darksaga
14th May 2007, 23:34
Hi,

I'm using a QSqlRelationalTableModel with two QSqlRelationalDelegates, comparable to the qt example: link (http://doc.trolltech.com/4.2/qsqlrelationaltablemodel.html)

In this example if I add a new City or Country (in the database), how do I tell the QSqlRelationalDelegates to update their data (tell the combobox to refresh the data)?

you can call something like

m_tableView->itemDelegate() to get a pointer to the QAbstractItemView but there's no method like refresh() or update().


Second question is:

Is it more efficient to implement a search for a QSqlRelationalTableModel using model->setFilter();model->select(); or is more performant to use a QSortFilterProxyModel between the QSqlRelationalTableModel and the QTableView e.g.:



QSqlRelationalTableModel model = new QSqlRelationalTableModel();

QSortFilterProxyModel proxyModel = new QSortFilterProxyModel();
proxyModel->setSourceModel(model );

QTableView tableView = new QTableView();
tableView->setModel(proxyModel );

grisumbras
9th November 2010, 01:54
After you add a city call the relationModel(int column) method of your QSqlRelationalTableModel to get a pointer to the model which stores data for delegate. Then call that model's select() method, e.g.
yourModel.relationalModel(foreignKeyColumn)->select();