show your eventFilter() method, then I can show you in the code.
show your eventFilter() method, then I can show you in the code.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
I install the eventfilter in the statement: pWidget->installEventFilter(this); in the QDirectManipulationWrapPanel class.
Now I can receive the pWidget's Paint, Polish and other event in the QDirectManipulationWrapPanel::eventFilter function,
but I can't receive the QEvent::MouseButtonPress in the QDirectManipulationWrapPanel::eventFilter function. thanks.
bool QDirectManipulationWrapPanel::eventFilter ( QObject * watched, QEvent * event )
{
if (watched == pWidget)
{
if (event->type() == QEvent::MouseButtonPress)
{
mousePressEvent((QMouseEvent*)event);
}
}
return QWidget::eventFilter(watched, event);
}
Please use the code tags when posting code.
Your eventFilter() is not doing enything with the event.
How do you know that MouseButtonPress is not being trapped?
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
I already resolve the problem, thank you. I need receive the child's child event, but I only monitor the child widget's event. Now I can receive the MouseButtonPress event.
Add the parent's parent widget's mouse event in the end of the mouse event in the parent widget.
e.g. QParentWidget inhrets QWidget, in the mouse event of QParentWidget wrote following:
void QParentWidget::mousePressEvent(QMouseEvent *event)
{
// do anything....
QWidget::mousePressEvent(event);
}
void QChildWidget::mousePressEvent(QMouseEvent *event)
{
// do anything....
}
Bookmarks