Greetings,
in python i used to set the QComboBox data and get part from my SQL using dictionaries, just like the code below:
// create a dict as a object, with this format: 'combobox.currentText':'table.field'
tcDic={'ID':'customer.id','Name':'customer.name', 'Phone':'customer.phone'}
// add these keys in combobox: ID, Name, Phone
combobox.addItems(tcDic.keys())
// in my custom sql, get dinamically the table field in the tcDic related with combobox.currentText
cur.execute("SELECT cutomer.id, customer.name, customer.phone FROM customer WHERE " + tcDic[str(self.combobox.currentText())] + "LIKE % " + str(lineedit.text() + " %")
// create a dict as a object, with this format: 'combobox.currentText':'table.field'
tcDic={'ID':'customer.id','Name':'customer.name', 'Phone':'customer.phone'}
// add these keys in combobox: ID, Name, Phone
combobox.addItems(tcDic.keys())
// in my custom sql, get dinamically the table field in the tcDic related with combobox.currentText
cur.execute("SELECT cutomer.id, customer.name, customer.phone FROM customer WHERE " + tcDic[str(self.combobox.currentText())] + "LIKE % " + str(lineedit.text() + " %")
To copy to clipboard, switch view to plain text mode
this way for me was simple and now i need to do something like that in C++. Someone would know if there a similar way or another way to do this kind of implementation?
observation: I know to reference objects straight in SQL is not recomended. I done this only for simplify this example
Best Regards!
Juliano
Bookmarks