I got a lineExdit and a tableView i want live update tableView base on typing text in lineEdit.
void updateTableView(QString *st)
{
QSqlQuery * qry = new QSqlQuery(mydb);
qry->prepare("select * from Poems where Title like ?%");
qry->addBindValue(st);
qry->exec();
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 theQString
.Assuming that the
QTableView
model is aQSqlQueryModel
then you should do the following: