how to move scrollbars simultaneously in qt
Asked Answered
D

2

5

I have two view whose perspectives are xy and xz. These views have their own scrollbars and x side of these views are equal. When i move scroll bar of x sides , i want x scrollbars to move simultaneously.

Class of views is QGraphicsView and scrollbars of these views are their own scrollbar. How can i make it? Any help will be appreciated.

Thanks

Drake answered 11/11, 2010 at 11:49 Comment(0)
Z
10

If I understand you correctly, you could simply do the following (if you use QScrollBar as your scrollbar)

connect(firstScrollbar, SIGNAL(valueChanged(int)), secondScrollbar, SLOT(setValue(int)));
connect(secondScrollbar, SIGNAL(valueChanged(int)), firstScrollbar, SLOT(setValue(int)));

Hope this answers your question and works for you.

Zoophobia answered 11/11, 2010 at 12:42 Comment(0)
K
0

I came across this trying to synchronize two PlainTextEdits. For that I also had to respond to the cursorPositionChanged signal to synchronize the scrolling when the keyboard is used (arrow keys, Page Up/Down) like so:

firstScrollbar.connect(SIGNAL('cursorPositionChanged()')) do
  secondScrollbar.setValue(firstScrollBar.value)
end

Code example is in Ruby via qtbindings

Keli answered 23/6, 2014 at 20:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.