Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[Solved] Making filter in QTableWidget



  • Good day, everyone.
    Tell me please, is there a way to make a filter in a QTableWidget? I know that I can use a QTreeView and QSortFilterProxyModel (i saw it in examples), but what about a QTableWidget.

    Thank you all!



  • QTableView is your better choice. By filtering you want to influence your data. That is what the model-view approach does : you need to work on your model.

    If you want to stick with QTableWidget you need to
    write a filter function yourself and use findItems() to get all the matching items in the table. Iterate the results to hide the filtered rows...



  • Thank you very much, Eddy! Im a newcomer in Qt, So I want to be sure that Im not miss something important. Thank you!



  • You're welcome.

    Please add [Solved] in front of your title.
    That way others know this is solved.


Log in to reply