PDA

View Full Version : [QTableView] Some cells and column headers not accessible (editable)



psychonaut
5th May 2011, 07:47
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:



- QTableView
- QSqlRelationalTableMode
- Subclassed QSortFilterProxyModel
- QSqlRelationalDelegate

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 = 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();

schnitzel
7th May 2011, 20:34
you didn't mention which cells and columns aren't editable.
what is the db you are trying to connect to?

Have you looked at: http://doc.qt.nokia.com/latest/sql-relationaltablemodel.html

psychonaut
9th May 2011, 07:16
My database is SQLITE. I have 12 columns and 4 of them are not editable.
Starting from left to right - the fourth, the fifth, the sixth and the seventh.

schnitzel
9th May 2011, 17:23
so, could there be something common between those 4 columns? Can you list how all fields are defined in the database?