PDA

View Full Version : how to get all the entries inside a QList view



aurora
10th February 2012, 05:53
Hi all,
I have a QList View...
Is there any function which return QStringList, which is list of all the entries inside the QListView?

ChrisW67
10th February 2012, 06:24
The data is in the model, not the view. If you are using a QStringList model the QStringList::stringList() is the obvious place to go. If you are using a different model type then you need to iterate over the rows of the model extract the display text from the column that is being shown in the QListView.

aurora
10th February 2012, 09:47
Now i have a QFileSystemModel and using QListView to display that model....
If i want to get all those list which is dispalyed, what i need to do? which function i should use?

AlexSudnik
10th February 2012, 11:17
In general , model's items do not necessarily have to store QStrings.However , if you do have QString's you may use :

QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const : to get an idex of a desired item.

and

QAbstractItemModel ::QVariant data ( const QModelIndex & index, int role = Qt:: DisplayRole ) const : to get the data you need.