Can't add widget from event call
<p>I want to add a button during a event, but for some reason it doesn't work.</p>

<p>If i run this code, the TempFunc function will run during creation and a button will be created.</p>

<pre><code>from PySide.QtGui import *
from PySide.QtCore import *
import sys
import math

class Example(QWidget):
   def __init__(self, val):
       super(Example,self).__init__()
       self.scrollAreaConstraint = QLabel()
       self.scrollAreaConstraint.setFixedSize(QSize(400,400))
       self.scroll = QScrollArea()
       self.scroll.setWidget(self.scrollAreaConstraint)
       self.scroll.setWidgetResizable(True) 
       layout = QVBoxLayout(self)
       layout.addWidget(self.scroll)

       self.CountSlider = QSlider()
       self.CountSlider.setOrientation(Qt.Orientation(1))
       layout.addWidget(self.CountSlider)
       self.TempFunc() #THIS WILL CREATE THE BUTTON!!


   def TempFunc(self):
       print "SLIDER PRESSED!!! NOW I WILL ADD A BUTTON"
       QPushButton(self.scrollAreaConstraint)

if __name__ == '__main__':

   import sys
   app = QApplication(sys.argv)
   window = Example(25)
   window.setGeometry(500, 500, 500, 400)
   window.show()
   sys.exit(app.exec_())
</code></pre>

<p>However running this, pressing the slider will cause the same TempFunc function to run, but the button is not created.</p>

<pre><code>from PySide.QtGui import *
from PySide.QtCore import *
import sys
import math

class Example(QWidget):
   def __init__(self, val):
       super(Example,self).__init__()
       self.scrollAreaConstraint = QLabel()
       self.scrollAreaConstraint.setFixedSize(QSize(400,400))
       self.scroll = QScrollArea()
       self.scroll.setWidget(self.scrollAreaConstraint)
       self.scroll.setWidgetResizable(True) 
       layout = QVBoxLayout(self)
       layout.addWidget(self.scroll)

       self.CountSlider = QSlider()
       self.CountSlider.setOrientation(Qt.Orientation(1))
       layout.addWidget(self.CountSlider)
       #self.TempFunc() #&lt;----Disabled!!
       self.CountSlider.sliderPressed.connect(self.TempFunc)


   def TempFunc(self):
       print "SLIDER PRESSED!!! NOW I WILL ADD A BUTTON"
       QPushButton(self.scrollAreaConstraint)

if __name__ == '__main__':

   import sys
   app = QApplication(sys.argv)
   window = Example(25)
   window.setGeometry(500, 500, 500, 400)
   window.show()
   sys.exit(app.exec_())
</code></pre>

<p>Why is the button not created when not being called directly from the "init"?</p>