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

Ingomar Wesp ingomar at wesp.name
Tue Apr 28 23:12:44 CEST 2009


On Monday 27 April 2009 23:09:50 Ingomar Wesp wrote:
> On Monday 27 April 2009 22:43:20 Malyushytsky, Alex wrote:
>> This might be useful for you.
>>
>> http://www.qtsoftware.com/developer/faqs/faq.2007-02-27.8405373153
>>
>> Example there is written for TableWidget, but it should be no difference
>> for any QAbstractItemView derived class as QListView is.

Ok, now I had some time to take a closer look and I'm afraid the answer in the 
FAQ can not be applied to my particular problem for the following reasons:

* QListView doesn't show headers and doesn't necessarily align items in a grid
  like a QTableView does (where looking at the visible header indices would be
  sufficient to determine the min/max visible rows/columns).

* Attempting to sample the top/left, bottom/right itesm by using 
  QListView::indexAt() and the viewport's dimensions is bound to fail because 
  of spacing between items (there may not be an item at the specified 
  coordinates).

* When allowing free movement, items can be moved/reordered by the user and 
  may even overlap, which also implies that the displayed model indices 
  might not be contiguous.

Seems there is no (reasonably simple) way of determining the visible items?

Best regards,
Ingo





More information about the Qt-interest-old mailing list