View Full Version : getting entry from QListView
herbstritter
20th March 2010, 12:36
Hi,
i have a QListView with an underlying QStringList as model, now i want to read out the currently selected string in my listView for further use. How would i do that?
viheaho
20th March 2010, 12:49
Here's an example how I would do it:
QListView list;
QString data;
.
.
.
data=list.data(list.currentIndex(),0).toString();
Lykurg
20th March 2010, 13:05
Use QAbstractItemView::currentIndex() and QModelIndex::data():
QString string = PointerToYourListView->currentIndex().data().toString();
You might want check if current index is valid.
herbstritter
20th March 2010, 17:02
thanks, works perfectly!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.