title: Open a second window in PyQt
body: <p>I'm trying to use pyqt to show a custom QDialog window when a button on a QMainWindow is clicked. I keep getting the following error: </p>
  
  <pre><code>$ python main.py 
  DEBUG: Launch edit window
  Traceback (most recent call last):
    File "/home/james/Dropbox/Database/qt/ui_med.py", line 23, in launchEditWindow
      dialog = Ui_Dialog(c)
    File "/home/james/Dropbox/Database/qt/ui_edit.py", line 15, in __init__
      QtGui.QDialog.__init__(self)
  TypeError: descriptor '__init__' requires a 'sip.simplewrapper' object but received a 'Ui_Dialog'
  </code></pre>
  
  <p>I've gone over several online tutorials, but most of them stop just short of showing how to use a non built-in dialog window. I generated the code for both the main window and the dialog using pyuic4. What I think should be the relevant code is below. What am I missing here?</p>
  
  <pre><code>class Ui_Dialog(object):
      def __init__(self, dbConnection):
          QtGui.QDialog.__init__(self)
          global c
          c = dbConnection
  
  class Ui_MainWindow(object):
      def __init__(self, dbConnection):
          global c
          c = dbConnection
  
      def launchEditWindow(self):
          print "DEBUG: Launch edit window"
          dialog = QtGui.QDialog()
          dialogui = Ui_Dialog(c)
          dialogui = setupUi(dialog)
          dialogui.show()
  
  class StartQT4(QtGui.QMainWindow):
      def __init__(self, parent=None):
          QtGui.QWidget.__init__(self, parent)
          conn = sqlite3.connect('meds.sqlite')
          c = conn.cursor()
          self.ui = Ui_MainWindow(c)
          self.ui.setupUi(self)
  
  def main():
      app = QtGui.QApplication(sys.argv)
      program = StartQT4()
      program.show()
      sys.exit(app.exec_())
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>Bonus question: since it looks like you can't pass arguments in pyqt function callbacks, is setting something which would otherwise be passed as an argument (the poorly named "c") to be global the best way to get information into those functions?</p>