You are abusing the pointers when it is not necessary, for example the QSqlQuery
is creating it using the dynamic memory, and you do not eliminate it, the same with the QString
.
Assuming that the QTableView
model is a QSqlQueryModel
then you should do the following:
...
// constructor
connect(your_le, &QLineEdit::textChanged, this, &YourClass::updateTableView);
...
void updateTableView(const QString & st)
{
QSqlQuery query(mydb);
query.prepare("select * from Poems where Title like ?");
query.addBindValue(QString("%1%").arg(st));
query.exec();
your_QSqlQueryModel->setQuery(query);
}