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

Malyushytsky, Alex alex at wai.com
Mon Apr 27 22:43:20 CEST 2009


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.

Hope this helps,
   Alex



-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Ingomar Wesp
Sent: Monday, April 27, 2009 12:59 PM
To: qt-interest at trolltech.com
Subject: [Qt-interest] QListView: Get indexes of visible items

Hello,

In the process of porting a Java/Swing application to Qt, I stumbled over the
following problem (I'm completely new to Qt, so please be lenient if this is
an easy one):

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.

Although, because this is going to be called quite a lot, it needs to be
reasonably fast and the QListView will have to many items,  iterating over all
of them is definitely not the way to go.

Anyone got any hints for me?

Best regards,
Ingomar Wesp
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest


---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."

"Please consider our environment before printing this email."




More information about the Qt-interest-old mailing list