0
我有一个分层结构的两个组合框。第一个组合框显示客户名单的列表,即来自MySQL数据库的不同公司。每个客户在不同城市都有分支机构。Python分层结构QcomboBox:清理列表
然后,当从combo-box1选项列表中选择客户名称时,例如, {Aldi,Meyer,Carrefour,WalMart},对于该特定客户,城市/分行列表将自动显示在组合框2中。类似的东西,例如:
combo1: chosen_customer [Aldi] --> cities:{NY, Boston, Berlin, Tokyo, London} then..
combo2: options {NY, Boston, Berlin, Tokyo, London}
问题是当我们再次选择了另一个客户,最终有分支机构的数量较少 - 例如
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}
这里是运行combo2,这就是所谓的每一个客户名称从列表中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[:]
和功能,增加了属于列表城市的每一个名字对该客户:
def addcomboCity(self,id,cityname):
self.comboCity.addItem(QtCore.QString())
self.comboCity.setItemText(id, QtGui.QApplication.translate("MainWindow", cityname, None, QtGui.QApplication.UnicodeUTF8))
我们试图用del来清理列表中的前一个内容,但它仍然得到相同的行为。
这是一个Qt或Python相关的问题?或者有一些我们在这里失踪?
所有的意见和建议,非常感谢。
Thanks Apt! 'clear()'解决了这个问题........ |:0), – ThreaderSlash 2010-01-03 06:36:42