Solved Search information on QTableView
-
Hi all
I want to make a function about searching on
QTableView
withQSqlQueryModel
.I think it is too cumbersome that if I use
QSqlQuery
to research the information from database.
And I have usedQCompleter
and connect the model so that I can input the key words Conveniently.what should I do next?
Best regards
Mihan -
BTW, if I insert data by the other
QSqlQuery
, does theQSqlQueryModel
know that and refresh the data automatically? -
@Mihan said in Search information on QTableView:
BTW, if I insert data by the other QSqlQuery, does the QSqlQueryModel know that and refresh the data automatically?
No
I want to make a function about searching on QTableView
You can e.g. iterate over the model's data and search for the things you want.
-
@Christian-Ehrlicher said in Search information on QTableView:
You can e.g. iterate over the model's data and search for the things you want.
I find
QSortFilterProxyModel
, maybe it can do what I want(searching).OTOH, how to refresh the data from
QSqlquerymodel
when the database was inserted new data? -
@Christian-Ehrlicher said in Search information on QTableView:
No
What about using the same
QSqlQuery
?QSqlQueryModel
set the sameQSqlQuery
and I use the sameQSqlQuery
to insert data. -
@Mihan said in Search information on QTableView:
maybe it can do what I want(searching).
This proxy is for filtering and sorting. Don't see why you need this for searching - the search functionality is the same as in it's base class QAbstractItemModel.
how to refresh the data from QSqlquerymodel when the database was inserted new data?
By using QSqlTableModel and doing the modifications through the model