[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyKDE] Searching in a list of strings
From:       Fredrik Juhlin <laz () strakt ! com>
Date:       2002-05-30 9:24:43
[Download RAW message or body]

On Thu, 2002-05-30 at 09:13, Janos Blazi wrote:
> I have a QListView containing up to 100,000 entries. Now I should like
> to implement some sort of search: The strings in the list view should be
> compared against an entered user string and only those strings in the
> list view, that contain the user string, should be shown.
> 
> How can I do this?
> 
> I thought, I should create an QListViewItemIterator and looking at the
> items in the QListView. But then, if I do the comparing in Python, I
> shall have to convert the QStrings back to Python strings and that will
> be very, very slow.
> Any hints, how to do this *as fast as possible*?
QListView::findItem() should do the trick:

QListViewItem * QListView::findItem ( const QString & text, int column,
ComparisonFlags compare = ExactMatch | CaseSensitive ) const 

Finds the first list view item in column column, that matches text and
returns the item, or returns 0 of no such item could be found. Pass
OR-ed together Qt::StringComparisonMode values in the compare flag, to
control how the matching is performed. The default comparison mode is
case-sensitive, exact match. 

//Fredrik

_______________________________________________
PyKDE mailing list    PyKDE@mats.gmd.de
http://mats.gmd.de/mailman/listinfo/pykde
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic