PDA

View Full Version : QWheelEvent not working in event(QEvent*e) reimplementation



Sergex
1st December 2011, 19:18
Hello

I am trying to catch the wheel event of my QGraphicsView subclass and for this I am reimplementing the event() method. When I do :


bool GraphicsView::event(QEvent* event)
{

if(event->type() == QEvent::Wheel){
qDebug("ENTERED")
return false;
}

return QGraphicsView::event(event);

}

This is just to test and I noticed that when I move the wheel the if statement never gets accessed. What is the proper way to say "if the event is a mouse wheel event" to be able to implement what I need inside the if statement??

Thanks.

Added after 24 minutes:

Found the problem, since I already also had an implementation of the wheelEvent in my QGV class I just forgot to call the super class in my implementation.
Adding QGraphicsView::wheelEvent() made the above work as expected

ChrisW67
1st December 2011, 22:47
Why not just reimplement wheelEvent in the first place?