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

Wilhelm wilhelm.meier at fh-kl.de
Mon Jan 28 17:12:09 CET 2013


Am 25.01.2013 16:49, schrieb Frank Hemer:
> 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:-(

There are two possibilities:

i) install an eventfilter
ii) use a QTimer to poll the scrollbar value and signal any changes (if 
any) (well, that's polling ...)

>
> 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
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>


-- 
Wilhelm




More information about the Interest mailing list