As I have some additional constraints on it, I am trying to implement custom scrolling on a QGraphicsView. My implementation used to work on Windows, but on X11, I got some problems even for very basic scrolling.
When I catch the mouse-press-event or mouse-move-event, I store the event. On the next move then, I calculate a delta between those mouse positions, and set the values of the horizontal and vertical scroll bars accordingly.
The problem now is that when a scrollbar value changes, I get another mouse move event (as a result of the graphics view moving under the mouse), which is just inverse to the delta that I put onto the scrollbars. So as a result, no scrolling is done (except some flicker).
The following implementation of a mouse move event will result two "phantom" mouse move events for each "real" event (user actually moves the mouse). Those phantom events come from the two QAbstractSlider::setValue() calls.
Qt Code:
{ ensureSceneFillsView(); hBar->setValue(hBar->value() + (isRightToLeft() ? delta.x() : -delta.x())); vBar->setValue(vBar->value() - delta.y()); storeMouseEvent(event); lastMouseEvent.setAccepted(false); event->accept(); }To copy to clipboard, switch view to plain text mode
How do I get scrolling to work properly?
Bookmarks