class MyForm(QtGui.QMainWindow): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_Form() self.ui.setupUi(self) QtCore.QObject.connect(self.ui.spinBox, QtCore.SIGNAL("valueChanged(int)"), self.createMyRow) def createMyRow(self, rows): howManyRows = self.ui.tableWidget.rowCount() diff = rows - howManyRows if diff > 0: start = howManyRows while rows > start: print(start) self.ui.tableWidget.insertRow(start) self.comboBoxNew = QtGui.QComboBox() self.comboBoxNew.setGeometry(QtCore.QRect(30, 480, 61, 21)) self.comboBoxNew.setMaxVisibleItems(2) self.comboBoxNew.setMaxCount(2) self.comboBoxNew.setObjectName("comboBox") self.comboBoxNew.addItem("") self.comboBoxNew.addItem("") self.comboBoxNew.setItemText(0, QtGui.QApplication.translate("Form", "color", None, QtGui.QApplication.UnicodeUTF8)) self.comboBoxNew.setItemText(1, QtGui.QApplication.translate("Form", "bw", None, QtGui.QApplication.UnicodeUTF8)) self.ui.tableWidget.setCellWidget(start,1,self.comboBoxNew) start = start +1
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_Form() self.ui.setupUi(self) QtCore.QObject.connect(self.ui.spinBox, QtCore.SIGNAL("valueChanged(int)"), self.createMyRow)