python - Properly handling a keyPressEvent in a Subclassed PyQT LineEdit -
so have qlineedit want catch shift keypress in.
here's code:
class notetext(qtgui.qlineedit): def __init__(self, parent): super (notetext, self).__init__(parent) def keypressevent(self, event): if (event.modifiers() & qtcore.qt.shiftmodifier): self.shift = true print 'shift!' as can guess, can catch shift keypress, cannot input text lineedit. i've tried catching keypresses, i'm not sure quite them allow user continue type widget.
what missing? thanks!
i guess want default behavior of overridden keypressevent method should call base class implementation, smth this:
def keypressevent(self, event): if (event.modifiers() & qtcore.qt.shiftmodifier): self.shift = true print 'shift!' # call base class keypressevent qtgui.qlineedit.keypressevent(self, event) hope helps, regards
Comments
Post a Comment