[Qt-qml] Flickable WebBrowser: how to update contentY property when user clicks on a same-page anchor ?
Sacha Zyto
sacha at mit.edu
Tue Sep 7 20:21:42 CEST 2010
Good afternoon
I have a WebView embedded inside a Flickable, and I'm trying to move the
page appropriately when a user clicks on a link that's an anchor to the
same page, such as:
<a href="#references">Jump to References</a>
I looked at the source code in demos/declarative/webbrowser, but I fear
that they may have forgotten about the use of links for that purpose,
since the code in FlickableWebView looks like:
(...)
onUrlChanged: {
// got to topleft
flickable.contentX = 0
flickable.contentY = 0
if (url != null) { header.editUrl = url.toString(); }
}
(...)
contentY shouldn't typically be set to 0 if the url changes just by the
anchor part (i.e. from http://www.example.com#section1 to
http://www.example.com#section2). My question is: Does the QML WebView
element exposes enough of its state in its API so that we can actually
scroll to the right place on the page ? If not, shouldn't we submit a
bug report or feature request ?
Example:
Use the demos/declarative/webbrowser QML example and visit
http://en.wikipedia.org/wiki/Uniform_Resource_Locator
... and try any of the "Contents" link: Instead of scrolling to the
right place on the page, it will go back to the top of the document.
Best,
Sacha
More information about the Qt-qml
mailing list