self.comboBox_2.addItems(self.citys[province] if province in self.citys.keys() else ["--请选择--"])
else:
self.comboBox_2.clear()
self.comboBox_2.addItem("--请选择--")
if __name__=="__main__":
app=QApplication(sys.argv)
win=WindowClass()
win.show()
sys.exit(app.exec_())
复制代码
注:这里的代码self.comboBox_1.currentText()可以调用当前激活的文本,self.comboBox_1.itemText(count)可以调用comboBox列表
print("状态:",self.comboBox_1.currentText())
# for count in range(self.comboBox_1.count()):
# print("列表选项:" ,self.comboBox_1.itemText(count),count)