PDA

View Full Version : Finding values in QTableview



ekapek
15th June 2010, 21:15
Hi

I have Qtableview with QSqlTablemodel and lineEdit, nextButton and prevButton

Now when I enter "value" in lineEdit I need to select row in Qtableview which contains %value% in first column How can I simple do this? After clicking nextButton I should found nextRow with %value%

ChrisW67
16th June 2010, 04:22
QAbstractItemModel::match() will find the model indexes of matching cells for an exact or starts-with match. You could re-implement the match() method if you need some other matching: you seem to using used SQL syntax, a regular expression could cater for this. Depending on exactly what is required you could also approach this using a QSortFilterProxyModel and do away with the Next/Prev buttons.