[Qt-interest] Scroll to anchor in QWebView?

Eric Clark eclark at ara.com
Thu Jan 28 17:22:42 CET 2010


Andre,

This would probably work; however, the URL that is being viewed is a custom URL that does not actually refer to a file. The URL tells me how to load the html and, if it is has an anchor, I need to scroll to that anchor in the document. The problem is, if I set the URL in the QWebView to my URL, the QWebView just shows a blank page. I could respond to the URL changing in the QWebView, which I do to set the html, but the view has already done what it can with the URL; therefore, it does not scroll to the anchor. The URLs work fine for me until I need to go to an anchor in the page. I do not see any functions to do this. I could obviously find the anchor via the QWebElement interface, but how can I scroll to that particular element in the page? I do not see any functions to do so. I thought about getting the bounding box of the web element and using that position to scroll to it, but my guess is that a <a name="somename"> tag has no geometry because it is not visible to the user. Any help with this would be greatly appreciated.

Eric

From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of André Somers
Sent: Thursday, January 28, 2010 1:33 AM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] Scroll to anchor in QWebView?

Just a guess...
Does it work to just change the URL to include the anchor?

André

Van: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] Namens Eric Clark
Verzonden: donderdag 28 januari 2010 5:24
Aan: Qt Interest (qt-interest at trolltech.com)
Onderwerp: [Qt-interest] Scroll to anchor in QWebView?

Hello All,

I would like to know if anyone knows of a way to force a QWebView to scroll to an anchor in the web page that it is currently showing?

Thanks,
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100128/5f573e4a/attachment.html 


More information about the Qt-interest-old mailing list