Hey Folks, I am looking to create a list within a QCombobox where the items
have a human-readable title but is referencing an underlying unique id.

My ComboBox will list a QStandardItemModel, which contains a QStandardItem
per project.

This is currently what I am doing:

for project in self.projects:
item = QtGui.QStandardItem()
item.setData(project['title'], QtCore.Qt.DisplayRole)
item.setData(project['id'], QtCore.Qt.UserRole)
item.setCheckable(False)
self.model.appendRow(item)

I then append the QStandardItemModel to the QCombobox and it displays the
title as expected - sweet! However, I am not sure how I will go about
retrieving the underlying id. Currently, I use projectList.currentText()
Which works for getting the
current display value of the combo box, but how do I reach the underlying
current QStandardItem and its id?

Also, if there's anything I have misunderstood regarding how to work with
these elements I'd be happy if it got pointed out.
Thanks!

-- 
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_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAEKd6bYF3zKggo3dJdFafvpKOM96b89ych0Vs7pK_T-v658A3A%40mail.gmail.com.

Reply via email to