Webview not scrollable using QtWebKit 1.0

678 views Asked by At

Im trying to use a webview in my qml code, but the scrolling is not wrking with those two versions of QtQuick and QtWebKit. Also I tried the Flickable Web View, the scroll works fine but fixed position content is not properly repositionned.

What I have to do to fix those problems?

P.S: When I use QtQuick 2.0 and QtWebKit 3.0, there is no problem, and for materials constraints I have to use the version 1.0 for both. And Im using the version 5.3 of QT.

This is my qml class:

import QtQuick 1.0
import QtWebKit 1.0


Rectangle {
  id: container
  width: 700
  height: 300

  property string initialUrl: "http://bootstrap2modaldemo.scripting.com/"

  Rectangle {
    id: thumbnailContainer
    color: "black"

    anchors.bottom: container.bottom
    width: container.width
 }

 Rectangle {
    id: content
    width: container.width
    color: "black"
    anchors {
        top: container.top
        bottom: thumbnailContainer.top
    }

    WebView {
        id: webView
        anchors.fill: parent
        width: container.width
        opacity: 1
        url: container.initialUrl
    }
  }
}
1

There are 1 answers

0
MrEricSir On

The original WebView does not include scrolling; you must wrap it in a Flickable if you want that behavior. From the documentation:

The WebView item includes no scrolling, scaling, toolbars, or other common browser components.

But as you pointed out, wrapping a WebView 1.0 in a Flickable is buggy. Under the hood, WebKit isn't completely aware of the Flickable's scroll position, so anything that relies on that feature (fixed positioning, setting the scroll position in Javascript, etc.) will not work out of the box.