Skip to content Skip to sidebar Skip to footer

How To Connect Qlineedit Focusoutevent

I have designed a window with a QLineEdit in PyQt4 with the help of Designer. I converted .ui to .py using pyuic4. I created another .py file and imported and subclassed Ui_Class.

Solution 1:

Use an eventFilter:

classFilter(QtCore.QObject):
    defeventFilter(self, widget, event):
        # FocusOut eventif event.type() == QtCore.QEvent.FocusOut:
            # do custom stuffprint'focus out'# return False so that the widget will also handle the event# otherwise it won't focus outreturnFalseelse:
            # we don't care about other eventsreturnFalse

And in your window:

# ...
self._filter = Filter()
# adjust for your QLineEdit
self.ui.lineEdit.installEventFilter(self._filter)

Post a Comment for "How To Connect Qlineedit Focusoutevent"