1, Qlist<qstandarditem *> qstandarditemmodel::finditems (const QString & text, Qt::matchflags flags = Qt:: matchexactly, int column = 0) const
When the second argument is not specified, this function searches only the top-level elements of the TreeView and does not match the child elements.
In the second argument, add the Qt::matchcontains | Qt::matchrecursive ", you can complete the matching of child elements.
However, this approach is particularly limited in that it is not possible to search for specific roles (datarole) data, but only to match displayrole data
2. Virtual Qmodelindexlist Match (const QMODELINDEX & Start, int role, const qvariant & value, int hits = 1, Qt::mat Chflags flags = qt::matchflags (Qt::matchstartswith | QT::MATCHWRAP)) const
Data for a particular role (datarole) can be solved using this function, which is similar to 1, the main difference being that you can specify the data role to match (Datarole, second argument)
In the second argument, add the Qt::matchcontains | Qt::matchrecursive ", you can complete the matching of child elements, and the default is to match only the top-level elements.
Example of usefulness: The second parameter is specified as Qt::checkstaterole, and all selected elements can be found to facilitate the fetching of these elements.