I would try to make it so that each of the items that needs to scroll in concert is inside its own QScrollArea
. I would then put all those widgets into one widget, with a QScrollBar
underneath (and/or to the side, if needed).
Designate one of the interior scrolled widget as the "master", probably the plot widget. Then do the following:
- Set every
QScrollArea
's horizontal scroll bar policy to never show the scroll bars.
- The master
QScrollArea
's horizontalScrollBar()
's rangeChanged( int min, int max )
signal to a slot that sets the main widget's horizontal QScrollBar
to the same range. Additionally, it should set the same range for the other scroll area widget's horizontal scroll bars.
- The horizontal
QScrollBar
's valueChanged( int value )
signal should be connected to every scroll area widget's horizontal scroll bar's setValue( int value )
slot.
- Repeat for vertical scroll bars, if doing vertical scrolling.
There is one place where I think this could go wrong, and that is mouse-wheel scrolling. You could solve this in a couple of ways. One would be to connect all the scrolling areas to a slot that triggers when their value changes, which updates all the other scroll bars. The other would be to install event filters on those widgets, and either ignore the scroll or process it with the main scroll bars.