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

Filter vector of strings



  • Hello,

    I have a table view with a vector<vector<string>> as underlaying data. Every string is a unique object. I would like to print in table only objects that contains specific pattern inserted in ui, like person name. I saw basicsortfiltermodel example, but didnt'show a costum implementation of this method proxyModel->setFilterRegularExpression(regularExpression), and I don't know to write one. Can someone give me an advice, please.


  • Lifetime Qt Champion

    Hi
    But do you need/want to filter by a regular expression ?

    If you have custom logic , you could just override
    https://doc.qt.io/qt-5/qsortfilterproxymodel.html#filterAcceptsRow
    and apply the logic there.

    else im not sure what you mean by a

    " but didnt'show a costum implementation of this method proxyModel->setFilterRegularExpression "

    as it simply accepts a regular expression.
    https://regexr.com/


Log in to reply