title: apply clicked on table header in pyqt
body: <p>this is my caller file which helps me generate ui of table where i can write data.the problem here is i want to sort the data when i click on the header of the table according to that column. i can sort the data easily as i have a backend data(not present in this code as it will not be needed here) but i am unable to apply click function on headers of the table. i want to apply clicked.connect on different table header. thanks in advance :)</p>
  
  <pre><code>from table import *
  from PyQt4 import QtGui # Import the PyQt4 module we'll need
  import sys # We need sys so that we can pass argv to QApplication
  import os
  
  from PyQt4.QtGui import *
  from PyQt4.QtCore import *
  
  
  class MainWindow(QMainWindow,Ui_MainWindow):
      def __init__(self, parent=None):
          QMainWindow.__init__(self, parent)
          self.setupUi(self)
  
  if __name__ == '__main__':
      app = QApplication(sys.argv)
      w = MainWindow()
      w.show()
      sys.exit(app.exec_())
  </code></pre>
  
  <p>this is my table.py which has ui code:</p>
  
  <pre><code># -*- coding: utf-8 -*-
  
  # Form implementation generated from reading ui file 'table.ui'
  #
  # Created by: PyQt4 UI code generator 4.11.4
  #
  # WARNING! All changes made in this file will be lost!
  
  from PyQt4 import QtCore, QtGui
  
  try:
      _fromUtf8 = QtCore.QString.fromUtf8
  except AttributeError:
      def _fromUtf8(s):
          return s
  
  try:
      _encoding = QtGui.QApplication.UnicodeUTF8
      def _translate(context, text, disambig):
          return QtGui.QApplication.translate(context, text, disambig, _encoding)
  except AttributeError:
      def _translate(context, text, disambig):
          return QtGui.QApplication.translate(context, text, disambig)
  
  class Ui_MainWindow(object):
      def setupUi(self, MainWindow):
          MainWindow.setObjectName(_fromUtf8("MainWindow"))
          MainWindow.resize(800, 600)
          self.centralwidget = QtGui.QWidget(MainWindow)
          self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
          self.gridLayout = QtGui.QGridLayout(self.centralwidget)
          self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
          self.tableWidget = QtGui.QTableWidget(self.centralwidget)
          self.tableWidget.setObjectName(_fromUtf8("tableWidget"))
          self.tableWidget.setColumnCount(3)
          self.tableWidget.setRowCount(3)
          item = QtGui.QTableWidgetItem()
          self.tableWidget.setVerticalHeaderItem(0, item)
          item = QtGui.QTableWidgetItem()
          self.tableWidget.setVerticalHeaderItem(1, item)
          item = QtGui.QTableWidgetItem()
          self.tableWidget.setVerticalHeaderItem(2, item)
          item = QtGui.QTableWidgetItem()
          self.tableWidget.setHorizontalHeaderItem(0, item)
          item = QtGui.QTableWidgetItem()
          self.tableWidget.setHorizontalHeaderItem(1, item)
          item = QtGui.QTableWidgetItem()
          self.tableWidget.setHorizontalHeaderItem(2, item)
          self.gridLayout.addWidget(self.tableWidget, 0, 0, 1, 1)
          MainWindow.setCentralWidget(self.centralwidget)
          self.menubar = QtGui.QMenuBar(MainWindow)
          self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 31))
          self.menubar.setObjectName(_fromUtf8("menubar"))
          MainWindow.setMenuBar(self.menubar)
          self.statusbar = QtGui.QStatusBar(MainWindow)
          self.statusbar.setObjectName(_fromUtf8("statusbar"))
          MainWindow.setStatusBar(self.statusbar)
  
          self.retranslateUi(MainWindow)
          QtCore.QMetaObject.connectSlotsByName(MainWindow)
  
      def retranslateUi(self, MainWindow):
          MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
          item = self.tableWidget.verticalHeaderItem(0)
          item.setText(_translate("MainWindow", "New Row", None))
          item = self.tableWidget.verticalHeaderItem(1)
          item.setText(_translate("MainWindow", "New Row", None))
          item = self.tableWidget.verticalHeaderItem(2)
          item.setText(_translate("MainWindow", "New Row", None))
          item = self.tableWidget.horizontalHeaderItem(0)
          item.setText(_translate("MainWindow", "Name", None))
          item = self.tableWidget.horizontalHeaderItem(1)
          item.setText(_translate("MainWindow", "class", None))
          item = self.tableWidget.horizontalHeaderItem(2)
          item.setText(_translate("MainWindow", "marks", None))
  
  
  if __name__ == "__main__":
      import sys
      app = QtGui.QApplication(sys.argv)
      MainWindow = QtGui.QMainWindow()
      ui = Ui_MainWindow()
      ui.setupUi(MainWindow)
      MainWindow.show()
      sys.exit(app.exec_())
  </code></pre>