Confused about keypress event

  • Hi,
    Im using pyside, and I am loading a ui file from designer with QUiLoader.

    @class MyWidget(QtGui.QMainWindow):
    def init(self, *args):
    apply(QtGui.QMainWindow.init, (self,) + args)

    loader = QtUiTools.QUiLoader()
    file = QtCore.QFile("pyside_demo.ui")
    self.ui = loader.load(file, self)

    def keyPressEvent(self, e):
    print "a key was pressed"
    if e.key() == QtCore.Qt.Key_Escape:
    print "escape was pressed"

    def show(self):

    I dont really know how to get the keypress event to work - at the moment it does not - any clues?

  • Perhaps you can upload your files somewhere so other people can try it on their local machine.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.