Hide rows from QTableView/QSqlRelationalTableModel
Hi,
I have created a tableview which uses as model a QSqlRelationalTableModel and then some buttons for adding and removing records. All works good.
When I run the program the table shows all records. Is it possible to hide some rows (for example rows with a field different from a given one) and still have a working add/remove record functions (with primary key)?
Thanks
Re: Hide rows from QTableView/QSqlRelationalTableModel
I'm trying this approach: to use QSqlRecord QSqlQueryModel::record(int row) in a for loop to check each row in the table; from each row I got the content of the desired field using QVariant QSqlRecord::value(int index).
Well, this in theory because with the code below I have an empty value returned from QSqlRecord::value() and so comparison fails
Code:
for(int i = 0; i < numRows; i++) {
if(record.value(field) != ui->articleComboBox->itemData(ui->articleComboBox->currentIndex()))
ui->scoopsTableView->hideRow(i);
}
Where is my error?
Re: Hide rows from QTableView/QSqlRelationalTableModel
Re: Hide rows from QTableView/QSqlRelationalTableModel
Very thanks, Lesiok. It worked fine.