Q:

How to receive scrollbar mouse events for QGraphicsView

In qt widget QGraphicsView I want to detect mouse-press, mouse-release and mouse-move events. 
I derived a class from QGraphicsView and I have overridden the following functions:

mousePressEvent(QMouseEvent *event)
mouseReleaseEvent(QMouseEvent *event)
mouseMoveEvent(QMouseEvent *event)

Now I can detect these mouse events almost everywhere, except for the area where are the scroll bars, which are part of QGraphicsView.
I want to be able to catch these events and move the scroll bar manually.
Edit:
I am trying to simulate second mouse in windows environment sending WM_LBUTTONDOWN,... events. I would like to be able to detect this events also for scroll bars in QGraphicsView.
Besides detecting the events I would like to know the event->x() and event->()y position. 

A:

QGraphicsView inherits the QAbstractScrollArea class. Thus the scrollbar widgets can be accessed with the QAbstractScrollArea::verticalScrollbar and QAbstractScrollArea::horizontalScrollbar methods.
You don't even have to use event filters once you can access the scrollbar object as the QScrollBar inherits QAbstractSlider and thus offers the signals:
QAbstractSlider::sliderPressed()
QAbstractSlider::sliderReleased()

So you can just connect them to your slots like:
connect(horizontalScrollBar(), SIGNAL(sliderPressed()), this, SLOT(doSomething()));
connect(horizontalScrollBar(), SIGNAL(sliderReleased()), this, SLOT(doSomething()));

If you need the position of the event, you will have to use event filter though. You can install an event filter on the widget object.

