Finditems Lookup subkey in Qtreeview __qtreeview

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.