title: KeyEvent in MainWindow (PyQt4)
body: <p>I'm trying to to build a GUI with PyQt4 and control some actions with the arrow keys. Nevertheless I fail to get the keystrokes.</p>
  
  <p>It have to be a simple issue, but I newbie to this. So any help will be appreciated. Thanks!</p>
  
  <pre><code>import sys
  from PyQt4 import QtCore, QtGui
  
  class Ui_MainWindow(object):
     def setupUi(self, MainWindow):
       MainWindow.setObjectName(_fromUtf8("MainWindow"))
       MainWindow.resize(910, 500)
       self.centralwidget = QtGui.QWidget(MainWindow)
       self.centralwidget.setObjectName(_fromUtf8("centralwidget"))  
  
       MainWindow.setCentralWidget(self.centralwidget)
       self.menubar = QtGui.QMenuBar(MainWindow)
       self.menubar.setGeometry(QtCore.QRect(0, 0, 240, 22))
       self.menubar.setObjectName(_fromUtf8("menubar"))
       MainWindow.setMenuBar(self.menubar)
       self.statusbar = QtGui.QStatusBar(MainWindow)
       self.statusbar.setObjectName(_fromUtf8("statusbar"))
       MainWindow.setStatusBar(self.statusbar)
  
    def keyPressEvent(self, event):
       key = event.key()
       print(key)
  
       if key == QtCore.Qt.Key_Left:
          print('Left Arrow Pressed')
  
  if __name__=='__main__':
    app = QtGui.QApplication(sys.argv)
    MainWindow = QtGui.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
  
    MainWindow.show()
    sys.exit(app.exec_())
  </code></pre>