Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to move scrollbars simultaneously in qt

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

like image 419
ibrahimyilmaz Avatar asked Nov 11 '10 11:11

ibrahimyilmaz


People also ask

How do I add a scrollbar to QT?

A QWidget does not have scrollbars, you need to add a zone which will have scrollbars. Just add a QScrollArea to your window, and put all the widgets in it (buttons, etc...). Don't forget to layout your scroll area to the whole main window.

How do I make my Qt widget scrollable?

You should create widget, fill it with proper layout and then use QScrollArea::setWidget(QWidget *) to make it scrollable.

What are vertical scrollbars?

A horizontal scroll bar enables the user to scroll the content of a window to the left or right. A vertical scroll bar enables the user to scroll the content up or down.


1 Answers

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.

like image 111
Live Avatar answered Oct 17 '22 14:10

Live