Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-11082

Implement a findItems() by data in QStandardItemModel

    XMLWordPrintable

Details

    Description

      In QStandardItemModel there is already a function with this signature:
      QList<QStandardItem *> findItems ( const QString & text, Qt::MatchFlags flags = Qt::MatchExactly, int column = 0 ) const

      However, it would be very practical to have a data/role-based way of searching for items, for comparison QComboBox has these functions:
      int findData ( const QVariant & data, int role = Qt::UserRole, Qt::MatchFlags flags = Qt::MatchExactly | Qt::MatchCaseSensitive ) const
      int findText ( const QString & text, Qt::MatchFlags flags = Qt::MatchExactly | Qt::MatchCaseSensitive ) const

      So what I would like is a similar function for QStandardItemModel with the signature:
      QList<QStandardItem *> findItems ( const QVariant & data, int role = Qt::UserRole, Qt::MatchFlags flags = Qt::MatchExactly, int column = 0 ) const

      The overall function would be the same, only the matching of items would be different. This probably applies to QTreeWidget, QListWidget and QTableWidget as well as I see they have the findItems method, but personally I only case about the QStandardItemModel. P.S. For Qt5 you should clean up if Qt::MatchCaseSensitive should be in the default or not so that it's consistent.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            kjella Kjell Rune Skaaraas
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes