?代码 ?
class CUi_comboboxDlg(QDialog,Ui_ComboBoxDlg):
def __init__(self,parent=None):
super(CUi_comboboxDlg, self).__init__(parent)
self.setupUi(self)
self.comboBox.currentIndexChanged.connect(self.selectionChange) #控件选择发生改变后 触发这个函数
def selectionChange(self,i):
self.label.setText(self.comboBox.currentText())
self.label.adjustSize()
for count in range(self.comboBox.count()):
print('item'+str(count)+'='+self.comboBox.itemText(count))
print('current index',i,'selection changed',self.comboBox.currentText())
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = CUi_comboboxDlg()
MainWindow.show()
sys.exit(app.exec_())
代码:pyqt5-combobox的使用,ui和业务分离版-Python文档类资源-CSDN下载
|