Hello,
I have a problem with QTableView and QSqlRelationalTableModel. The problem is that few cells and column headers are not editable. It's even not clickable.
The following are the conditions:
- QSqlRelationalTableMode
- QTableView
- QSqlRelationalTableMode
- Subclassed QSortFilterProxyModel
- QSqlRelationalDelegate
To copy to clipboard, switch view to plain text mode
Thanks in advice! I hope I didn't forget anything, but if anything is missing, just ask!
Edit: Maybe I should post some more information:
model->setTable("Protokoll");
proxy = new proxymodel(tableView);
// ------
model
->setRelation
(12,
QSqlRelation("Status",
"ID",
"Status"));
tableView
->setSelectionMode
(QTableView::SingleSelection);
tableView
->setSelectionBehavior
(QTableView::SelectRows);
proxy->setSourceModel(model);
tableView->setModel(proxy);
tableView->hideColumn(0);
tableView->setSortingEnabled(true);
model->select();
model = new QSqlRelationalTableModel( tableView );
model->setTable("Protokoll");
proxy = new proxymodel(tableView);
// ------
model->setRelation(12,QSqlRelation("Status", "ID", "Status"));
model->setEditStrategy(QSqlTableModel::OnFieldChange);
tableView->setSelectionMode(QTableView::SingleSelection);
tableView->setSelectionBehavior(QTableView::SelectRows);
tableView->setEditTriggers(QAbstractItemView::DoubleClicked);
proxy->setSourceModel(model);
tableView->setModel(proxy);
tableView->hideColumn(0);
tableView->setItemDelegate(new QSqlRelationalDelegate(this));
tableView->setSortingEnabled(true);
model->select();
To copy to clipboard, switch view to plain text mode
Bookmarks