C++ (Qt)void Object::someMethod(){ ... lineEdit->installEventFilter(this); ...} bool Object::eventFilter(QObject* obj, QEvent* event){ if (obj == lineEdit && event->type() == QEvent::MouseButtonPress) doSmth();}
C++ (Qt)class LineEdit : public QLineEdit{ Q_OBJECTpublic: LineEdit( QWidget* parent = 0 ) : QLineEdit( parent ) {} Q_SIGNALS: void clicked(); protected: void mousePressEvent( QMouseEvent* e ) { QLineEdit::mousePressEvent( e ); emit clicked(); }};