Get data from PySide combobox model

I have a data model and a QListView widget. Filling widget with setModel:


If I need to get data from the selected row

model_index = self.listProjects.currentIndex()
project_id = + 1)

So far so good, but it does not work with QComboBox

asset_index = self.comboboxAsset.currentIndex()

returns integer instead of QModelIndex… How should I retrieve data from QComboBox?

With a QComboBox you should be able to use currentText to get the string value

Right, but I don`t need string as well, I need to have access to my data (same as with QListView, so I can get anything I need from the database)!

asset_index = self.comboboxAsset.model().index(self.comboboxAsset.currentIndex(), 0)
asset_id = + 1)
1 Like