PDA

View Full Version : QSqlTableModel :: setFilter() not working



gotronics
13th August 2017, 16:25
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
model->setTable("people");
model->setFilter("name = 'tinashe'");
model->select();

ui->tableView->setModel(model);


I am trying to filter every name and only display " tinashe " I only get blank table view but when I substitute with
model->setFilter("ID = 1 );
IT WORKS WELL .

please assist where am I wrong

d_stranz
13th August 2017, 17:09
Is there a "name" field in your table? And is the entry you are trying to filter actually "tinashe" (and not "Tinashe")?

gotronics
13th August 2017, 18:27
thank you very much I solved the problem it was name did not match what was in database because when I edited before it using SQLITE database manager which did not submit the change into the database. so I deleted the table and created another one .