Python:如何创建一个显示comboBox值的setText()?

时间:2018-10-23 16:29:51

标签: mysql python-3.x pyqt5

我有一个数据库('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)

0 个答案:

没有答案