Results 1 to 5 of 5

Thread: QWebView autoscroll to bottom

  1. #1
    Join Date
    Sep 2009
    Location
    Warsaw/Poland
    Posts
    56
    Thanks
    8
    Thanked 4 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QWebView autoscroll to bottom

    Hello,

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

    Qt Code:
    1. webView->page()->mainFrame()->setScrollPosition(QPoint(0, webView->page()->mainFrame()->scrollBarMaximum(Qt::Vertical)));
    To copy to clipboard, switch view to plain text mode 

    any suggestion ?

  2. #2
    Join Date
    Sep 2009
    Location
    Warsaw/Poland
    Posts
    56
    Thanks
    8
    Thanked 4 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWebView autoscroll to bottom

    Ok, I found solution:
    Qt Code:
    1. webView->page()->mainFrame()->setScrollBarValue(Qt::Vertical, webView->page()->mainFrame()->scrollBarMaximum(Qt::Vertical));
    To copy to clipboard, switch view to plain text mode 

  3. The following 4 users say thank you to mero for this useful post:

    grantbj74 (2nd August 2012), thanyaj (1st March 2011), wendelmaques (6th January 2011), Xagen (3rd April 2011)

  4. #3
    Join Date
    Nov 2010
    Posts
    22
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: QWebView autoscroll to bottom

    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.

  5. #4
    Join Date
    Mar 2008
    Location
    Houston, Texas, USA
    Posts
    277
    Thanks
    9
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QWebView autoscroll to bottom

    well I used this code

    Qt Code:
    1. void
    2. ChatViewPrivate::contentsSizeChanged(const QSize& size)
    3. {
    4. if (!userMoved) {
    5. mainFrame()->scroll(size.width(), size.height());
    6. }
    7. }
    To copy to clipboard, switch view to plain text mode 

    And connect it to http://doc.qt.nokia.com/4.7-snapshot...ntsSizeChanged

    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.
    Qt-4.7.3 | Gentoo ~amd64 | KDE-4.7
    Aki IRC Client for KDE4 | Qt Documentation

  6. #5
    Join Date
    Aug 2009
    Location
    Brisbane, Australia
    Posts
    75
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWebView autoscroll to bottom

    I wonder why this doesn't work?
    Qt Code:
    1. webView->triggerPageAction(QWebPage::MoveToEndOfDocument);
    To copy to clipboard, switch view to plain text mode 

    I wanted to scroll to the top so did:
    Qt Code:
    1. webView->page()->mainFrame()->setScrollBarValue(Qt::Vertical, 0);
    To copy to clipboard, switch view to plain text mode 

    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.

Similar Threads

  1. ScrollArea:AutoScroll to setfocus'ed control
    By BalaQT in forum Qt Programming
    Replies: 4
    Last Post: 26th October 2009, 05:39
  2. Autoscroll in ScrollArea
    By BalaQT in forum Qt Programming
    Replies: 2
    Last Post: 26th October 2009, 05:37
  3. Replies: 7
    Last Post: 15th November 2007, 17:19
  4. Autoscroll QTextBrowser
    By aLiNuSh in forum Newbie
    Replies: 4
    Last Post: 24th March 2007, 12:27
  5. Listbox Autoscroll is not happening?
    By mahe2310 in forum Qt Programming
    Replies: 4
    Last Post: 9th March 2006, 09:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.