[Qt-interest] How to get index of a QListView when no selection

Ross Bencina rossb-lists at audiomulch.com
Sun May 22 08:09:10 CEST 2011


Aaron Lewis wrote:
> How can i get the index of arbitrary entry in a QListView ?

see docs for QAbstractItemModel::index

QModelIndex index = listView()->model()->index( row, column );

> I need to retrieve the contents of the first entry in a QListView 

if( index.isValid() )
    QVariant data = index.data();

Is that what you wanted?

Ross



More information about the Qt-interest-old mailing list