Access QT Designer Objects Programmatically
<p>Disclaimer: New to both python and qt designer</p>

<p>QT Designer 4.8.7</p>

<p>Python 3.4</p>

<p>PyCharm 5.0.3</p>

<p>Question - How do I add controls to the main form or a scroll area widget on the main form (created in QT Designer) programmatically?</p>

<p>I have created a MainWindow in qt designer and added my widgets. The following is the entire test program in PyCharm:</p>

<pre><code>import sys
from PyQt4 import QtGui, QtCore,  uic

from PyQt4.QtGui import *

from PyQt4.QtCore import *

qtCreatorFile = "programLauncher.ui"

Ui_MainWindow, QtBaseClass = uic.loadUiType(qtCreatorFile)

class MyApp(QtGui.QMainWindow, Ui_MainWindow):
def __init__(self):
    QtGui.QMainWindow.__init__(self)
    Ui_MainWindow.__init__(self)
    self.setupUi(self)

    # Cannot resize or maximize
    self.setFixedSize(1045, 770)

    # Add button test
    self.dateLabel = QtGui.QLabel("Test")
    self.pushButton = QtGui.QPushButton('Test button')

    # self.scrollArea_programs.addWidget()

    grid = QtGui.QGridLayout()
    # self.scrollArea_programs.addWidget(self.pushButton)
    grid.addWidget(self.dateLabel,0,0)
    grid.addWidget(self.pushButton,0,1)
    self.setLayout(grid)

    self.pushButton_exit.clicked.connect(self.closeEvent)

def closeEvent(self):
    QtGui.QApplication.quit()


if __name__ == "__main__":
  app = QtGui.QApplication(sys.argv)
  window = MyApp()
  window.show()
  sys.exit(app.exec_())
</code></pre>

<p>As you can see I tried to add controls to a grid but nothing shows up when the program runs - I have also tried to add a control to the scroll area. Can someone help me to just add 1 control to the scroll area at run time - so then I can know the proper way to do it or "a" proper way to do this.</p>

<p>Thanks in advance </p>