Search information on QTableView
-
Hi all
I want to make a function about searching on
QTableViewwithQSqlQueryModel.I think it is too cumbersome that if I use
QSqlQueryto research the information from database.
And I have usedQCompleterand connect the model so that I can input the key words Conveniently.what should I do next?
Best regards
Mihan -
@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
QSqlquerymodelwhen the database was inserted new data? -
@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:
No
What about using the same
QSqlQuery?QSqlQueryModelset the sameQSqlQueryand I use the sameQSqlQueryto insert data. -
@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
QSqlquerymodelwhen the database was inserted new 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