我有一个数据库('texpalsac'),Qtdesigner(ventas.ui)和一个表(产品):
PRODUCTS
COD NAME
111 bag
112 shoes
121 pants
122 t-shirts
我希望每次我选择comboBox('comboArt'显示'COD'列)时,setText都会在'products'表中显示其第二列(NAME)。我不知道该怎么做。 谢谢
class MiFormulario(QDialog, QComboBox):
def __init__(self, parent=None):
super(MiFormulario, self).__init__(parent)
uic.loadUi('Venta.ui', self)
self.model = QtSql.QSqlTableModel (self)
self.model.setTable ("products")
self.model.select ()
self.comboArt.setModel (self.model)
self.comboArt.setModelColumn(0)