[Qt-interest] QListView: Get indexes of visible items

Arnold Krille arnold at arnoldarts.de
Wed Apr 29 22:39:45 CEST 2009


Hi,

On Monday 27 April 2009 21:59:11 Ingomar Wesp wrote:
> I need to get the model indices for all items that are currently visible in
> a QListView (essentially the inverse of QAbstractItemView::
> visualRegionForSelection). I know there's an indexAt function, but I'm not
> comfortable with using it with the top left and bottom right viewport
> coordinates because of spacing between items.

Why not iterate over the coordinates from top-left to bottom-right in steps of 
10px? That gives you a limited number of calls to indexAt() and should still 
pick all items. Or you make the step-size depending on the base font size, 
then it should be independent of the actual size of the items...

But I would be very curious why you need to know the visible items at all?

Have fun,

Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090429/9e4aebe4/attachment.bin 


More information about the Qt-interest-old mailing list