0

my cuestion is: there is a way to search for two or more strings (the union of results) @ FILTRO->setFilterFixedString(searchText1); FILTRO->setFilterFixedString(searchText2); @ i already know how to find the intersection that have the two Qstrings, or simply just one of them, but not the union that have one of the strings or the other or both

thank you

1 Answers1

0

You have to use a regular expresion for your purpose. Try setFilterRegExp with something like this:

const QString firstString = "Hello";
const QString secondString = "Bye";
const QString exp = QString("/^.*?(?:\b|_)%1(?:\b|_).*?(?:\b|_)%2(?:\b|_).*?$/m").arg(firstString, secondString);
QRegExp regExp(exp);

Now use this expresion in the QSortFilterProxyModel class.

I didnt test this expression, is just an example. You will find a complete explanation in this link: Regular expression to find two strings anywhere in input

Community
  • 1
  • 1
mohabouje
  • 3,867
  • 2
  • 14
  • 28