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

Change in behaviour of QListWidget::findItems

    XMLWordPrintable

Details

    • All
    • 4b197c3f5 (dev), 7261a2298 (dev)

    Description

      I'm not sure if this is a bug in the code or in the documentation, but the behaviour of QListWidget::findItems("*", Qt::MatchWildcard) changed between 5.14 and 5.15, when matching items that contain "/" characters.

      I haven't checked the 5.14 implementation, but I figure it's due to changing QAbstractItemModel::match() from using QRegExp to QRegularExpression.

      I have attached an example project to demonstrate the 'problem', but it boils down to the fact that QRegularExpression::wildcardToRegularExpression treats path separators as special, while QRegExp doesn't when doing wildcard matching.

      The fix in client code is of course simple - change from a wildcard pattern to a regular expression, but, at least for me, this was a surprising change that took a fair while to debug, and I didn't spot anything in the documentation about it. I'm also not that experienced in using QAbstractItemModel, but I'm not sure if users would really expect that using Qt::MatchWildcard should imply that text that happens to contain '/' will be treated specially.

      QRegularExpression::wildcardToRegularExpression("*") -> "\\A(?:[^/]*)\\z"
      

      and that no longer matches "a/b".

      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
            michael.partridge Michael Partridge
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes