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

Provide a QListWidget::findData(...) method

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • None
    • Widgets: Itemviews
    • None
    • All

    Description

      Would it be feasible to provide a means to search the `data` portion of QListWidgetItems held in a QListWidget? Currently, I note there is a method to search the text part only:

       

      QList<QListWidgetItem*> QListWidget::findItems(const QString&text, Qt::MatchFlags flags) const

      Finds items with the text that matches the string text using the given flags.

      I would like to draw a comparison with the QComboBox widget which instead returns an index rather than a list of item pointers but can do so for both the text entry specifically but also for any data role as well:

      int QComboBox::findData(const QVariant&data, int role = Qt::UserRole, Qt::MatchFlags flags = static_cast<Qt::MatchFlags>(Qt::MatchExactly|Qt::MatchCaseSensitive)) const

      Returns the index of the item containing the given data for the given role; otherwise returns -1.

      The flags specify how the items in the combobox are searched.

      int QComboBox::findText(const QString&text, Qt::MatchFlags flags = Qt::MatchExactly|Qt::MatchCaseSensitive) const

      Returns the index of the item containing the given text; otherwise returns -1.

      The flags specify how the items in the combobox are searched.

      Attachments

        For Gerrit Dashboard: QTBUG-85402
        # Subject Branch Project Status CR V

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            slysven Stephen Lyons
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes