PDA

View Full Version : Synchronize Scrollbar of QGraphicsView



hereiam
8th July 2020, 23:50
Hi there,

how can I synchronize the ScrollBar of two QGraphicsView objects?

Ginsengelf
9th July 2020, 07:52
Hi, you can get the scrollbars using horizontalScrollBar() or verticalScrollBar(), then connect the valueChanged() signal of one scrollbar to the setValue() slot of the other.
I hope this does not trigger an endless loop of changes...

Ginsengelf

d_stranz
9th July 2020, 18:30
I hope this does not trigger an endless loop of changes...

You can always check to see if the sender() is yourself or if the new position is the same as the old position. If either one is true, you do nothing and the loop stops. I don't remember if setPos() results in a signal or not.