[Development] Qt::MatchRecursive on QTreeWidget does not work

wim delvaux wim.delvaux at adaptiveplanet.com
Wed Feb 15 03:01:28 CET 2017


First let me say that I am no newbie to Qt.  In fact I have been using Qt
since v 1.

I checked the source code and found this in qtreewidget.cpp (near line
3050) method findItems

d->model->match(model()->index(0, column,
QModelIndex()), Qt::DisplayRole, text, -1, flags
);

The model is a QTreeModel (in qtreewidget_p.h)

Now QAbstractItemModel says that in order to search in multiple columns,
one needs to reimplement the match method.  Now QTreeModel does not do this.

So how can Qt::MatchRecursive work ?

W

On Wed, Feb 15, 2017 at 1:17 AM, Marc Mutz <marc.mutz at kdab.com> wrote:

> On Tuesday 14 February 2017 23:46:45 wim delvaux wrote:
> > I have this code on a QTreeWidget in Qt 5.7 on Linux
> >
> >     Qt::MatchFlags F = Qt::MatchRecursive | Qt::MatchContains |
> > Qt::MatchWrap | Qt::MatchFixedString;
> >
> >     if( ui->Regex_CB->isChecked() ) {
> >         F |= Qt::MatchRegExp;
> >     }
> >
> >     CurrentMatches = ui->Output_TW->findItems( Txt, F );
> >
> > I would expect the currentMatches to contain all items that contain a Txt
> > snippet.  However it only returns the items with the text snippet in
> column
> > 0
>
> Please provide a self-contained example and file an issue at
> bugreports.qt.io.
>
> Thanks,
> Marc
>
> --
> Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
> KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
> Tel: +49-30-521325470
> KDAB - The Qt, C++ and OpenGL Experts
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20170215/fffa1342/attachment.html>


More information about the Development mailing list