title: Accessing dynamically added widgets (pyqt)
body: <p>I want add text into a text box which I've added using a push button based on the accepted answer for this question : <a href="https://stackoverflow.com/questions/8651742/dynamically-adding-and-removing-widgets-in-pyqt">Dynamically adding and removing widgets in pyqt</a></p>
  
  <p>My problem however is that I cannot access the text boxes I've added. <a href="https://stackoverflow.com/questions/3077192/get-a-layouts-widgets-in-pyqt">This</a> post tells me that I can use <code>itemAt()</code> to loop through items added when using <code>addWidget()</code> to add to layout. However I can only access the 'inner layout'  of type <code>QWidgetIem</code> </p>
  
  <p>Here's my code : - </p>
  
  <pre><code>from PyQt4 import QtGui, QtCore
  import sys
  
  class Main(QtGui.QMainWindow):
      def __init__(self, parent = None):
          super(Main, self).__init__(parent)
  
          # main button
          self.addButton = QtGui.QPushButton('button to add other widgets')
          self.addButton.clicked.connect(self.addWidget)
  
          # scroll area widget contents - layout
          self.scrollLayout = QtGui.QHBoxLayout()
  
          # scroll area widget contents
          self.scrollWidget = QtGui.QWidget()
          self.scrollWidget.setLayout(self.scrollLayout)
  
          # scroll area
          self.scrollArea = QtGui.QScrollArea()
          self.scrollArea.setWidgetResizable(True)
          self.scrollArea.setWidget(self.scrollWidget)
  
          # main layout
          self.mainLayout = QtGui.QVBoxLayout()
  
          # add all main to the main vLayout
          self.mainLayout.addWidget(self.addButton)
          self.mainLayout.addWidget(self.scrollArea)
  
          # central widget
          self.centralWidget = QtGui.QWidget()
          self.centralWidget.setLayout(self.mainLayout)
  
          # set central widget
          self.setCentralWidget(self.centralWidget)
  
  
  
  
  
      def addWidget(self):
          self.scrollLayout.addWidget(Test())
  
          # This doesn't work
          print self.scrollLayout.itemAt(0)
  
  class Test(QtGui.QWidget):
      def __init__(self, parent=None):
          super(Test, self).__init__(parent)
  
       # Sensor Indicator
          self.pushButton = QtGui.QPushButton()
          self.pushButton.setStyleSheet("background-color: green")
  
       # Console Window to display sensor data
          self.logOutput = QtGui.QTextEdit()
          self.logOutput.setReadOnly(True)
          self.logOutput.setLineWrapMode(QtGui.QTextEdit.NoWrap)
          self.font = self.logOutput.font()
          self.font.setFamily("Courier")
          self.font.setPointSize(10)
  
  
          layout = QtGui.QVBoxLayout()
          layout.addWidget(self.pushButton)
          layout.addWidget(self.logOutput)
          self.setLayout(layout)
  
  
  
  app = QtGui.QApplication(sys.argv)
  myWidget = Main()
  myWidget.show()
  app.exec_()
  </code></pre>