PDA

View Full Version : QScrollArea::scrollContentsBy does not work



Mad Max
19th April 2006, 12:46
Hi,

In Qt3 the QScrollView class had setContentsPos method, using it I as able to move the contents. I want to find a substitute of this in Qt4. I did think the scrollContentsBy method has the similar sense, but it does update the contents only. I need some method which move the contents in the scroll area.
I tried to use :


scrollArea->scrollContentBy(dx, dy); // does not work
scrollArea->viewport()->scroll(dx, dy); // It does move the contents, but does not update values of scrollbars.
scrollArea->widget()->move(widget()->x() + dx, widget()->y() + dy); // same like viewport()->scroll(dx, dy)

The question is: in what way I can reproduce the behaviour of Qt3's QSrollView::setContentsPos in Qt4?

jacek
19th April 2006, 15:48
Try:
const int x = scrollArea->horizontalScrollBar()->value() + dx;
scrollArea->horizontalScrollBar()->setValue( x );

const int y = scrollArea->verticalScrollBar()->value() + dy
scrollArea->verticalScrollBar()->setValue( y );