How to get first item of a QListView

538 views
Skip to first unread message

Mahmoodreza Aarabi

unread,
May 7, 2016, 5:22:23 AM5/7/16
to Python Programming for Autodesk Maya
Hello guys

I want to know that how can i get text of elements of a QListView that filled with a model.

currentIndex?
currentRow?
or there is a way to access to its elements?

thanks

Mahmoodreza Aarabi

unread,
May 7, 2016, 7:08:05 AM5/7/16
to python_in...@googlegroups.com

i found the solution with helps of justin and Roy, thanks.

we can set index 0 of listView as highlighted item in this way:

index = self.model.index(0, 0)
self.list_view.setCurrentIndex(index)

and for getting text of current selected item of listView:

current_index = self.list_view.currentIndex()
item = current_index.data(QtCore.Qt.DisplayRole)

good luck!


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/312ce01f-1d48-46a7-a39a-d0b656d048d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--


Bests,
madoodia
Reply all
Reply to author
Forward
0 new messages