Solved Listmodel with Search or filter option In QML?
-
In that program consists of textfield and below that listview. The data is obtained from the listmodel and displayed in the listview. The selected list data will be appear in the textfield. If I filter the listview based on the text entered in the textfield appear below the textfield. so, I need logic for filter or search in listview based on the entered data in the textfield in QML.
-
@eswar
QML supports C++ models.
Thus the most effective way is to subclass QSortFilterProxyModel and register the subclass to QML. -
Hi @raven-worx
Thank you for your reply. I already go through that. Any other option in QML itself?
-
@eswar
no QML is rather limited regarding creating models, and thats good IMHO. -
@raven-worx Thanks for your quick reply..
-
One hack to make this in QML is to set the delegate visibility and height based on a filter i.e. something like:
visible: RegExp(txtField.text,"i").test(name)
height: visible ? 20 : 0where name is the listmodel field you wan't to filter. But as said this is a hack not a proper solution.
-
@samakkon Oh. Ok...Thanks