Hi Everybody,
I have a hierarchical two combo-box. The first combo-box displays a list of customerNames, i.e. different companies from a MySQL db. Each customer has branches in different cities.
Then, when a customer name is chosen from combo-box1 option list, e.g. {Aldi, Meyer, Carrefour, WalMart}, for that particular customer, a list of cities/branches is automatically displayed in the combo-box2. Something like that, e.g.:
combo1: chosen_customer [Aldi] --> cities:{NY, Boston, Berlin, Tokyo, London} then..
combo2: options {NY, Boston, Berlin, Tokyo, London}
The problem comes when we chose again another customer, that eventually has a smaller number of branches - e.g.
combo1: chosen_customer [Meyer] --> {LA, San Francisco}, then.. we got
combo2: options {LA, San Francisco, Berlin, Tokyo, London}
intead of combo2: options {LA, San Francisco}
Here is the function that runs the combo2, which is called every time a customerName is chosen from the list combo1:
def loadComboCity(self,customerName):
"""query results cityList into self.mydb.matrix"""
queryName="citylist_thisCustomer"
self.mysqlAPI(queryName,customerName)
id=0
for row in self.mydb.matrix:
cityname=self.mydb.matrix[id][0]
self.addcomboCity(id,cityname)
id=id+1
del self.mydb.matrix[:]
and the function that adds each name of the list city that belongs to that customer:
def addcomboCity(self,id,cityname):
self.comboCity.addItem(QtCore.QString())
self.comboCity.setItemText(id, QtGui.QApplication.translate("MainWindow", cityname, None, QtGui.QApplication.UnicodeUTF8))
We tried to use del to clean the previous content of the list, but it still gets the same behavior.
This is a Qt or a Python related problem? Or there is some bit that we are missing here?
All comments and suggestions are highly appreciated.