Search code examples
c++qtqgraphicsview

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


Solution

  • 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.