PDA

View Full Version : Find QObjects that insatlled event filter



babu198649
15th December 2010, 06:55
Hi all,
Is it possible to find the QObjects that installed event filter on an QObject.
Suppose there are two QObjects
QObject *objA;
QObject *objB;
b->installEventFilter(a);
// using object objA can i retrive the object objB which has installed event filter on it.

Thanks

high_flyer
15th December 2010, 10:43
I am not sure I follow.
B is the object you want to filter its events, and you know that, since you call b->installEventFilter().
In A, the eventFileter() method takes a parmeter with the object that currently triggered the incoming event, so you know its B (in A).

So what exactly is missing for you?

babu198649
15th December 2010, 10:58
void foo(QObject *objA)
{
QObject *objB = new QObject;
objB->setEventFilter(objA);
}

int main()
{
QObject *objA = new QObject;
foo(objA);
// after the call i want to get the list of QObjects who has set the eventFilters
// on objA, somthing like QList<QObject*> list = objA->getEventFilters();
// Now list.at(0) will contain objB pointer.
}

wysota
15th December 2010, 11:36
What do you need such a list for? Maybe there is a better approach to your problem?

high_flyer
15th December 2010, 12:27
// after the call i want to get the list of QObjects who has set the eventFilters
// on objA, somthing like QList<QObject*> list = objA->getEventFilters();
// Now list.at(0) will contain objB pointer.

Can't you do something like:


void foo(QObject *objA)
{
QObject *objB = new QObject;
objB->setEventFilter(objA);
g_filterList.push_back(objB);
}