Reputation: 299
I have a QLineEdit which I set an eventFilter using installEventFilter(this). Is it possible to pass in parameters to this eventFilter? For example, I want multiple QLineEdits to all call the same eventFilter, but I need to pass in a parameter in order to be able to tell which QLineEdit box caused the event to occur.
Thanks in advance!
Upvotes: 0
Views: 608
Reputation: 99
The sender object is already passed to eventFilter as first parameter. So you are able to determine which QLineEdit is dispatched like this:
bool eventFilter(QObject *obj, QEvent *ev) {
if (obj == lineEdit1) {
// event from lineEdit1
} else if (obj == lineEdit2) {
// event from lineEdit2
}
}
Upvotes: 1