Qt-interest Archive, March 2007
Is this a limitation with the QSqlQueryModel?
Message 1 in thread
I have a table with 20 columns and want to display around 8 columns in a grid view. I use the QSqlQueryModel and QTableView making use of the model/view architecture. After user inserts a new record into the table, this grid needs to be updated with the newly added row in the table. Subclassing QSqlQueryModel and implementing
virtual bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex()); seems to be the way to do it but there is no member in QSqlQueryModel to add the new row. Whereas the QStringListModel has a member called "lst" of type QStringList as shown below in the code
bool QStringListModel::insertRows(int row, int count, const QModelIndex &parent)
{
Q_UNUSED(parent);
if (count < 1 || row < 0 || row > rowCount(parent))
return false;
beginInsertRows(QModelIndex(), row, row + count - 1);
for (int r = 0; r < count; ++r)
lst.insert(row, QString());
endInsertRows();
return true;
}
Is this a limitation with the QSqlQueryModel?
Thank you.
qt_coder.
---------------------------------
Looking for earth-friendly autos?
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.