Quantcast
Channel: QtWebEngine
Viewing all articles
Browse latest Browse all 13965

[[qanda:topic_unsolved]] QML WebEngineView elements integrate in page and scroll

$
0
0

Hello, I have been suffering from this problem for a long time, maybe someone will help, I will be grateful.
there is a page where the web element is mounted in this page, but it does not fit the entire area, when you try to scroll, nothing happens in the element area. Everything works when to scroll through the green area (all in the example). The question is how to catch (handle) the WebEngineView focus?

if scroll green region = all is well
if mouse cursor in web page = does not scroll
but left click and swipe works

example

import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Window 2.12
import QtWebEngine 1.8
Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    Flickable{
        id: pageFlickable
        width: parent.width
        height: parent.height

        Column {
            anchors.fill: parent
            Rectangle{
                width: parent.width
                height: 150
                color: "#93d905"
            }
            Item{
                id: descriptionTextForm
                width: parent.width
                height: webView.height

                WebEngineView {
                    id: webView
                    x:15
                    y:15
                    width: descriptionTextForm.width - 60
                    settings.focusOnNavigationEnabled: false

                    onContextMenuRequested: function(request) {
                        request.accepted = true
                    }

                    onHeightChanged: {
                            pageFlickable.contentHeight = webView.height + 150
                    }

                    onScrollPositionChanged: {
                       // console.log("scroll: " + scrollPosition.y)
                    }

                    onNewViewRequested: function(request) {
                        Qt.openUrlExternally(request.requestedUrl)
                    }

                    url: "https://www.qt.io/blog"
                    onLoadingChanged: {

                        webView.runJavaScript(
                                    "document.documentElement.scrollHeight;", function (i_actualPageHeight) {webView.height = i_actualPageHeight; });

                        if (loadRequest.errorString)
                            console.error(loadRequest.errorString);
                    }
                }
            }
        }
        ScrollBar.vertical: ScrollBar {
            width: 15
            policy: ScrollBar.AlwaysOn
        }
    }
}

Viewing all articles
Browse latest Browse all 13965

Trending Articles