Details
-
Suggestion
-
Resolution: Unresolved
-
P4: Low
-
4.6.2
-
None
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.