我有一张桌子,有4列。 这4个专栏中有两个是关于特性的。一是特色,二是子功能。 在每列中,所有单元格都有组合框。 我可以在这些单元格中打开txt。 我想:当我选择电影院作为专题时,我只想在子功能组合框中看到电影的名称,而不想看到我“数据”中的所有子功能。。。当我在功能中选择食物时,我只想在我的子功能组合框中看到食物的类型。。。在
。。我不知道怎么做。。。有办法吗?在
我的定义是在表中放入组合框,并在这些组合框中打开文本文件:
def createEd(self, parent, option, index):
if index.column() == POLARITY:
combobox = QComboBox(parent)
combobox.addItems(sorted(index.model().TPolarities))
combobox.setEditable(True)
arquivo = codecs.open("ln2.txt",encoding='utf-8',mode="r")
conTWordsdo = arquivo.readlines()
lista =[]
for i in conTWordsdo:
lista.append(i.replace("\n",""))
combobox.addItems(sorted(lista))
return combobox
elif index.column() == FEATURE:
combobox = QComboBox(parent)
combobox.addItems(sorted(index.model().TFeatures))
combobox.setEditable(True)
arquivo = codecs.open("ln1.txt",encoding='utf-8',mode="r")
conTWordsdo = arquivo.readlines()
lista = []
for i in conTWordsdo:
lista.append(i.replace("\n",""))
combobox.addItems(sorted(lista))
return combobox
elif index.column() == SUBFEATURE:
combobox = QComboBox(parent)
combobox.addItems(sorted(index.model().TSubFeatures))
combobox.setEditable(True)
arquivo = codecs.open("ln3.txt",encoding='utf-8',mode="r")
conTWordsdo = arquivo.readlines()
lista = []
for i in conTWordsdo:
lista.append(i.replace("\n",""))
combobox.addItems(sorted(lista))
return combobox
elif index.column() == SENTENCE:
editor = QLineEdit(parent)
self.connect(editor, SIGNAL("returnPressed()"), self.commitAndCloseEditor)
return editor
else:
return QItemDelegate.createEditor(self, parent, option, index)
您将使用currentIndexChanged信号,如下所示:
相关问题 更多 >
编程相关推荐