Reputation: 841
I need to get the selected value in my qcombobox. It was populated from database, the QCombobox is named cbUser This is my function that populate the qcombobox:
for row in self.SELECT_USERS_ACCOUNTS():
self.cbUser.addItem(str(row[1]),int(row[0]))
The data is showed successfully in the qcombobox cbUser. and I get a function to will get the value to the selected item:
def getValue(self):
id_us = self.cbUser.itemData(self.cbUser.currentIndex())
print(str(id_us))
The print shows and it's not the data, the correct data is an integer value for example 1 or 2 .... Please help me, thanks in advance.
UPDATED: The solution was to modify the first line code into getValue function (add .toPyObject()):
id_us = self.cbUser.itemData(self.cbUser.currentIndex()).toPyObject()
Upvotes: 0
Views: 2112
Reputation: 841
The solution was to modify the first line code into getValue function (add .toPyObject()):
id_us = self.cbUser.itemData(self.cbUser.currentIndex()).toPyObject()
With this I saw the value stored in the qcombobox.
Upvotes: 1