Reputation: 810
I am working with python plugins.I designed my form using pyqt4 designer.It has one combobox. I coded in python as follows:
self.db._exec_sql(c, "SELECT "+column_name1+" from "+table_name+" ")
for row in c.fetchall():
print row
self.comboBox.addItem(row)
row gives me all the values of specific column of specific table. I am listing all column values from database into combobox.But self.comboBox.addItem(row) gives error saying :
TypeError: arguments did not match any overloaded call:
QComboBox.addItem(QString, QVariant userData=QVariant()): argument 1 has unexp
ected type 'tuple'
QComboBox.addItem(QIcon, QString, QVariant userData=QVariant()): argument 1 ha
s unexpected type 'tuple'
How do i list values in combobox??
Upvotes: 0
Views: 3187
Reputation: 57874
fetchall()
method yields tuples, even when you select only one value in the SQL SELECT
clause. Change your code to:
for row in c.fetchall():
self.comboBox.addItem(row[0])
Upvotes: 5