[Interest] How to get/manipulate the scrollbars of QWebView

Frank Hemer frank at hemer.org
Fri Jan 25 16:49:43 CET 2013


On Friday 25 January 2013 16:11:20 Wilhelm wrote:
> Am 25.01.2013 15:36, schrieb Frank Hemer:
> > On Friday 25 January 2013 15:05:38 Wilhelm wrote:
> >> Am 25.01.2013 14:04, schrieb Frank Hemer:
> >>> On Friday 25 January 2013 13:47:45 Wilhelm wrote:
> >>>> Hi all,
> >>>> 
> >>>> this may be a very dumb question: how get access to the scrollbars of a
> >>>> QWebView?
> >>>> 
> >>>> I want to connect to the sliderMoved() signal to store the actual
> >>>> position for later use.
> >>> 
> >>> You can use javascript to achieve this:-)
> >> 
> >> Well, that's weird!
> >> 
> >> No chance from C++ to do this?
> > 
> > Then I guess you're looking for this:
> > 
> > QWebFrame * frame = webView->page ()->mainFrame ();
> > 
> > and use frame's methods:
> > scrollPosition/scrollBarValue and setScroppPosition/setScrollBarValue
> 
> no, the code needs a notifier (aka signal) if the slider position
> changes! QScrollBar has this signal, but I can't figure out how to get
> QScrollBar objects.

You can't.
The sliders you are talking about are created by webkit (from the page source 
aka html) and are not QAbstractSlider instances. Thus you cannot access their 
signals.

However it should be possible to achieve this via javascript - by registering 
an eventListener for the scrollbar that in turn calls some c++ method.
But sorry - no codesnippet available:-(

A hint can be found here:
http://stackoverflow.com/questions/9615194/is-it-possible-to-call-a-c-
function-from-javascript-in-a-qwebview

Frank




More information about the Interest mailing list