title: How to get input from QTextEdit in PyQt4
body: <p><strong>how do i solve the following problem</strong>
  i am unable to get text from QTextEdit and insert it into Database...</p>
  
  <p>Code:</p>
  
  <pre><code>import sys
  import MySQLdb
  #from PyQt4.QtCore import *
  from PyQt4.QtGui import *
  
  e1=None
  e2=None
  
  def window():
      app=QApplication(sys.argv)
      win=QWidget()
      win.setWindowTitle("Sample")
      vbox=QVBoxLayout()
      e1 = QTextEdit()
      e2 = QTextEdit()
      vbox.addWidget(e1)
      vbox.addWidget(e2)
      vbox.addStretch()
      b1=QPushButton("Tap it!")
      vbox.addWidget(b1)
      b1.clicked.connect(b1_action)
      win.setGeometry(100,100,200,50)
      win.setLayout(vbox)
      win.show()
      sys.exit(app.exec_())
  
  def b1_action():
      print "Button Clicked"
      db = MySQLdb.connect('localhost', 'root', 'mysql', 'Tecoc354')
      cursor=db.cursor()
      x1=e1.toPlainText()
      x2=e2.toPlainText()
      print x1," ",x2," "
      #sql="create table Sample(addr varchar(10),name varchar(10))"
     # cursor.execute(sql)
      sql2="insert into Tecoc354.sample values(%s,%s)"%(x1,x2)
      cursor.execute(sql2)
      db.commit()
      db.close()
  
  window()
  </code></pre>