Hi
I am trying to hook up a spin box to create rows in a table and automatically populate them with comboboxes .. I have manged to use the signal/slot mechanism to create the extra rows of the table (from the sigbnal of the spinbox) and the first row has the correct comboboxes (created on startup)- but I cannot figure out how to create and populate the new rows with new combo boxes.
The following is the code ...

Qt Code:
  1. # -*- coding: utf-8 -*-
  2.  
  3. # Form implementation generated from reading ui file 'table6.ui'
  4. #
  5. # Created: Tue Jul 27 16:31:53 2010
  6. # by: PyQt4 UI code generator 4.7.3
  7. #
  8. # WARNING! All changes made in this file will be lost!
  9.  
  10. from PyQt4 import QtCore, QtGui
  11. import functools
  12.  
  13. class Ui_Form(object):
  14. def setupUi(self, Form):
  15. Form.setObjectName("Form")
  16. Form.resize(465, 531)
  17. self.tableWidget = QtGui.QTableWidget(Form)
  18. self.tableWidget.setGeometry(QtCore.QRect(20, 70, 351, 201))
  19. self.tableWidget.setRowCount(1)
  20. self.tableWidget.setColumnCount(3)
  21. self.tableWidget.setObjectName("tableWidget")
  22. self.tableWidget.setColumnCount(3)
  23. self.tableWidget.setRowCount(1)
  24. item = QtGui.QTableWidgetItem()
  25. self.tableWidget.setHorizontalHeaderItem(0, item)
  26. item = QtGui.QTableWidgetItem()
  27. self.tableWidget.setHorizontalHeaderItem(1, item)
  28. item = QtGui.QTableWidgetItem()
  29. self.tableWidget.setHorizontalHeaderItem(2, item)
  30. self.comboBox = QtGui.QComboBox(Form)
  31. self.comboBox.setGeometry(QtCore.QRect(30, 480, 61, 21))
  32. self.comboBox.setMaxVisibleItems(2)
  33. self.comboBox.setMaxCount(2)
  34. self.comboBox.setObjectName("comboBox")
  35. self.comboBox.addItem("")
  36. self.comboBox.addItem("")
  37. self.comboBox_2 = QtGui.QComboBox(Form)
  38. self.comboBox_2.setGeometry(QtCore.QRect(150, 480, 121, 21))
  39. self.comboBox_2.setMaxVisibleItems(2)
  40. self.comboBox_2.setMaxCount(2)
  41. self.comboBox_2.setObjectName("comboBox_2")
  42. self.comboBox_2.addItem("")
  43. self.comboBox_2.addItem("")
  44. self.tableWidget.setCellWidget(0,1,self.comboBox)
  45. self.tableWidget.setCellWidget(0,2,self.comboBox_2)
  46. self.tableWidget.setColumnWidth(2,120)
  47.  
  48. self.pushButton = QtGui.QPushButton(Form)
  49. self.pushButton.setGeometry(QtCore.QRect(300, 20, 75, 25))
  50. self.pushButton.setObjectName("pushButton")
  51. self.spinBox = QtGui.QSpinBox(Form)
  52. self.spinBox.setGeometry(QtCore.QRect(200, 20, 53, 22))
  53. self.spinBox.setProperty("value", 1)
  54. self.spinBox.setObjectName("spinBox")
  55. self.label = QtGui.QLabel(Form)
  56. self.label.setGeometry(QtCore.QRect(20, 20, 141, 16))
  57. self.label.setObjectName("label")
  58. self.pushButton_2 = QtGui.QPushButton(Form)
  59. self.pushButton_2.setGeometry(QtCore.QRect(20, 300, 91, 25))
  60. self.pushButton_2.setObjectName("pushButton_2")
  61.  
  62.  
  63. self.retranslateUi(Form)
  64. self.comboBox.setCurrentIndex(0)
  65. self.comboBox_2.setCurrentIndex(0)
  66. QtCore.QObject.connect(self.spinBox, QtCore.SIGNAL("valueChanged(int)"), self.createMyRow)
  67.  
  68.  
  69.  
  70.  
  71. #QtCore.QMetaObject.connectSlotsByName(Form)
  72.  
  73. def retranslateUi(self, Form):
  74. Form.setWindowTitle(QtGui.QApplication.translate("Form", "Add Passes", None, QtGui.QApplication.UnicodeUTF8))
  75. self.tableWidget.horizontalHeaderItem(0).setText(QtGui.QApplication.translate("Form", "Name", None, QtGui.QApplication.UnicodeUTF8))
  76. self.tableWidget.horizontalHeaderItem(1).setText(QtGui.QApplication.translate("Form", "Type", None, QtGui.QApplication.UnicodeUTF8))
  77. self.tableWidget.horizontalHeaderItem(2).setText(QtGui.QApplication.translate("Form", "Surface", None, QtGui.QApplication.UnicodeUTF8))
  78. self.comboBox.setItemText(0, QtGui.QApplication.translate("Form", "color", None, QtGui.QApplication.UnicodeUTF8))
  79. self.comboBox.setItemText(1, QtGui.QApplication.translate("Form", "bw", None, QtGui.QApplication.UnicodeUTF8))
  80. self.comboBox_2.setItemText(0, QtGui.QApplication.translate("Form", "closest surface", None, QtGui.QApplication.UnicodeUTF8))
  81. self.comboBox_2.setItemText(1, QtGui.QApplication.translate("Form", "opacity filtering", None, QtGui.QApplication.UnicodeUTF8))
  82. self.pushButton.setText(QtGui.QApplication.translate("Form", "Passes", None, QtGui.QApplication.UnicodeUTF8))
  83. self.label.setText(QtGui.QApplication.translate("Form", "How many passes", None, QtGui.QApplication.UnicodeUTF8))
  84. self.pushButton_2.setText(QtGui.QApplication.translate("Form", "Add Passes", None, QtGui.QApplication.UnicodeUTF8))
  85.  
  86. def createMyRow(self, rows):
  87. howManyRows = self.tableWidget.rowCount()
  88. diff = rows - howManyRows
  89. if diff > 0:
  90. start = howManyRows
  91. while rows > start:
  92. print(start)
  93. self.tableWidget.insertRow(start)
  94. self.comboBoxNew = QtGui.QComboBox(Form)
  95. start = start +1
To copy to clipboard, switch view to plain text mode 

I am also running this to start the gui..
Qt Code:
  1. #!/usr/bin/python -d
  2.  
  3. import sys
  4. from PyQt4 import QtCore, QtGui
  5. from table8 import Ui_Form
  6.  
  7. # Lars set this path to where you have my scripts!
  8. sys.path += ['/jobs/generic/shots/lightDome/qtDesigner']
  9.  
  10. class MyForm(QtGui.QMainWindow):
  11. def __init__(self, parent=None):
  12. QtGui.QWidget.__init__(self, parent)
  13. self.ui = Ui_Form()
  14. self.ui.setupUi(self)
  15. #QtCore.QObject.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"), self.ui.textEdit.clear )
  16. #QtCore.QObject.connect(self.ui.lineEdit, QtCore.SIGNAL("returnPressed()"), self.add_entry)
  17.  
  18. if __name__ == "__main__":
  19. app = QtGui.QApplication(sys.argv)
  20. myapp = MyForm()
  21. myapp.show()
  22. sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode 

I guess
self.comboBoxNew = QtGui.QComboBox(Form)
in createMyRow(self, rows):
doesn't know about Form but I don' know how to get around this
Thanks in advance
stephen