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

Expose completingModel as ProxyModel

    XMLWordPrintable

Details

    Description

      When I attach a QCompleter, I can use its completionModel as input to, e.g., a QListView. This is great for using a QLineEdit + QCompleter combination as a filter input to allow the user to search/filter items in the list.

      The problem arises when I need to interact with items in the list. Let's have a look at the signature:

      QAbstractItemModel *QCompleter::completionModel() const

      This signature hides the fact that QCompleter uses a (subclass of) QAbstractProxyModel. This renders signals that provide me with a ModelIndex pretty much useless, as I cannot call QAbstractProxyModel::mapToSource().

      I suggest to change the signature such as:

      QAbstractProxyModel *QCompleter::completionModel() const

      My current workaround is ugly:
      auto proxy = qobject_cast<const QAbstractProxyModel*>(completer->completionModel());

      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
            ypnos Johannes Jordan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes