Hello,
I'm trying to intercept wheel events in an event filter and it's not working. Here is the filter:
{
if (event
->type
() == QEvent::MouseButtonPress) {
QMouseEvent *mouseEvent
= static_cast<QMouseEvent
*>
(event
);
mousePressEvent(mouseEvent);
return true;
}
else if (event
->type
() == QEvent::MouseButtonRelease) {
QMouseEvent *mouseEvent
= static_cast<QMouseEvent
*>
(event
);
mouseReleaseEvent(mouseEvent);
return true;
}
else if (event
->type
() == QEvent::Wheel) {
QWheelEvent *wheelEvent
= static_cast<QWheelEvent
*>
(event
);
wheelEvent(wheelEvent);
return true;
}
// Continue standard event processing.
return QObject::eventFilter(obj, event
);
}
bool KeyframeArea::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::MouseButtonPress)
{
QMouseEvent *mouseEvent = static_cast<QMouseEvent *> (event);
mousePressEvent(mouseEvent);
return true;
}
else if (event->type() == QEvent::MouseButtonRelease)
{
QMouseEvent *mouseEvent = static_cast<QMouseEvent *> (event);
mouseReleaseEvent(mouseEvent);
return true;
}
else if (event->type() == QEvent::Wheel)
{
QWheelEvent *wheelEvent = static_cast<QWheelEvent *> (event);
wheelEvent(wheelEvent);
return true;
}
// Continue standard event processing.
return QObject::eventFilter(obj, event);
}
To copy to clipboard, switch view to plain text mode
The filter works for button press and release. For the wheelEvent call I get the error message: `wheelEvent' cannot be used as a function. What's wrong with this? QWheelEvent is included and void wheelEvent(QWheelEvent* event) is declared.
Bookmarks