PDA

View Full Version : Sync QScrollArea scrollbar and QTableWidget scrollbar



STM
4th August 2015, 09:12
Hi,

i have a qscrollarea and a qtablewidget on a form. In the qscrollarea there is a widget which is bigger than the form, so the scrollarea shows the scrollbars. What i want is, when i move the scrollbar of the tablewidget, that the scrollbar of the scrollare also moves synchronously.

I've tried this
connect(tablewidget->horizontalScrollBar(), SIGNAL(valueChanged(int)), scrollArea->horizontalScrollBar(), SLOT(setValue(int)));but the scrollarea bar moves only small steps while the tablewidget is already at the end. Is there another way to keep two scrollbars in sync?

Thank you.

//EDIT

Additionally i want the qscrollarea (i think it is the viewport) have always the same width as the tablewidget (viewport). How can i do this.