Auryn
18th July 2008, 10:25
PROBLEM:
In a QTableView, if a row has a null value in a combo box field (that writes in the row the value of a foreign key), the user does not see the row (!).
MORE INFORMATION:
I need to have a form where the user enters information about something in a QTableView (for the sake of clarity, I have chosen an example of a database of poems).
Some poems would have author and others not; (the author would be the foreign key). if I try a code like this:
QSqlRelationalTableModel model;
model.setEditStrategy(QSqlTableModel::OnManualSubm it);
model.setTable("poems");
model.setRelation(3, QSqlRelation( "authors", "author_id", "name"));
model.setHeaderData(0, Qt::Horizontal, t("ID"));
model.setHeaderData(1, Qt::Horizontal, t("Title"));
model.setHeaderData(2, Qt::Horizontal, t("Year"));
model.setHeaderData(3, Qt::Horizontal, t("Author"));
model.select();
QTableView table_view;
table_view->setModel(model);
table_view->setItemDelegate(new QSqlRelationalDelegate(table_view));
Then the rows that are poems without an author... are not shown.:eek:
In a QTableView, if a row has a null value in a combo box field (that writes in the row the value of a foreign key), the user does not see the row (!).
MORE INFORMATION:
I need to have a form where the user enters information about something in a QTableView (for the sake of clarity, I have chosen an example of a database of poems).
Some poems would have author and others not; (the author would be the foreign key). if I try a code like this:
QSqlRelationalTableModel model;
model.setEditStrategy(QSqlTableModel::OnManualSubm it);
model.setTable("poems");
model.setRelation(3, QSqlRelation( "authors", "author_id", "name"));
model.setHeaderData(0, Qt::Horizontal, t("ID"));
model.setHeaderData(1, Qt::Horizontal, t("Title"));
model.setHeaderData(2, Qt::Horizontal, t("Year"));
model.setHeaderData(3, Qt::Horizontal, t("Author"));
model.select();
QTableView table_view;
table_view->setModel(model);
table_view->setItemDelegate(new QSqlRelationalDelegate(table_view));
Then the rows that are poems without an author... are not shown.:eek: