So all you have to do is something like this:
{
Q_OBJECT;
public:
{
//... examine the event and return true or false
}
};
{
Q_OBJECT;
public:
{
//... examine the event and return true or false
}
};
// Somefile.cpp
Filter1 * filter1 = new Filter1( this );
Filter2 * filter2 = new Filter2( this );
frame1->installEventFilter( filter1 );
frame2->installEventFilter( filter2 );
class Filter1 : public QObject
{
Q_OBJECT;
public:
bool eventFilter( QObject * object, QEvent * event )
{
//... examine the event and return true or false
}
};
class Filter2 : public QObject
{
Q_OBJECT;
public:
bool eventFilter( QObject * object, QEvent * event )
{
//... examine the event and return true or false
}
};
// Somefile.cpp
QFrame * frame1 = new QFrame( this );
QFrame * frame2 = new QFrame( this );
Filter1 * filter1 = new Filter1( this );
Filter2 * filter2 = new Filter2( this );
frame1->installEventFilter( filter1 );
frame2->installEventFilter( filter2 );
To copy to clipboard, switch view to plain text mode
So now all events for frame1 will be sent first to the filter1 instance of Filter1, likewise for frame2. If either filter eats the event, the respective frame will not see it. Otherwise, after the filter is done with it, the event will then be forwarded to the frame. In the eventFilter() method for filter1, the QObject argument will point to frame1, likewise for filter2.
Bookmarks