I have different types of QWidgets into a DockWindow:
And I need scrolling all of them at the same time with the same scrollbar when I zoom in. I know two solutions for this:
What is the best solution to this? Do you know any scrollArea tutorial?
Thank you so much
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:
QScrollArea
's horizontal scroll bar policy to never show the scroll bars.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.QScrollBar
's valueChanged( int value )
signal should be connected to every scroll area widget's horizontal scroll bar's setValue( int value )
slot.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.