PDA

View Full Version : QWebView autoscroll to bottom



mero
21st April 2010, 00:49
Hello,

How Can I auto scroll to bottom of page using QWebView ?
I was trying this code, but it doesn't work...


webView->page()->mainFrame()->setScrollPosition(QPoint(0, webView->page()->mainFrame()->scrollBarMaximum(Qt::Vertical)));

any suggestion ?

mero
22nd April 2010, 01:41
Ok, I found solution:


webView->page()->mainFrame()->setScrollBarValue(Qt::Vertical, webView->page()->mainFrame()->scrollBarMaximum(Qt::Vertical));

jins
30th November 2010, 22:51
I have also tried to implement this code to enable auto scrolling on a webview but with no success. Did this actually work for you?

Can anyone please provide an example.

ComaWhite
1st December 2010, 09:03
well I used this code



void
ChatViewPrivate::contentsSizeChanged(const QSize& size)
{
if (!userMoved) {
mainFrame()->scroll(size.width(), size.height());
}
}


And connect it to http://doc.qt.nokia.com/4.7-snapshot/qwebframe.html#contentsSizeChanged

You can remove the if check as I need that in my code so it won't scroll automatically when the user has moved the scrollbar. When they moved it to the end it would scroll again.

grantbj74
2nd August 2012, 06:48
I wonder why this doesn't work?


webView->triggerPageAction(QWebPage::MoveToEndOfDocument);


I wanted to scroll to the top so did:


webView->page()->mainFrame()->setScrollBarValue(Qt::Vertical, 0);


Anyone know how to scroll to say chapters of a page?

I suppose you could do similar and hard code scrollbar position, but that would be ugly, especially if the HTML is modified.