Skip to content Skip to sidebar Skip to footer

Properly Handling A Keypressevent In A Subclassed Pyqt Lineedit

So I have a QLineEdit that I want to catch a shift keypress in. Here's my code: class NoteText(QtGui.QLineEdit): def __init__(self, parent): super (NoteText, self).__i

Solution 1:

I guess you want the default behavior of the overridden keyPressEvent method you should call the base class implementation, smth like this:

defkeyPressEvent(self, event):
    if (event.modifiers() & QtCore.Qt.ShiftModifier):
        self.shift = Trueprint'Shift!'# call base class keyPressEvent
    QtGui.QLineEdit.keyPressEvent(self, event)

hope this helps, regards

Post a Comment for "Properly Handling A Keypressevent In A Subclassed Pyqt Lineedit"