【问题标题】:Webview not scrollable using QtWebKit 1.0Webview 不能使用 QtWebKit 1.0 滚动
【发布时间】:2014-08-26 21:23:29
【问题描述】:

我试图在我的 qml 代码中使用 webview,但滚动不适用于这两个版本的 QtQuick 和 QtWebKit。 我也试过Flickable Web View,滚动效果很好,但fixed position content is not properly repositionned

我必须做些什么来解决这些问题?

P.S:当我使用 QtQuick 2.0 和 QtWebKit 3.0 时,没有问题,并且对于材料限制,我必须同时使用 1.0 版本。我使用的是 QT 5.3 版。

这是我的 qml 课程:

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
    }
  }
}

【问题讨论】:

    标签: qt webview qml qtwebkit flickable


    【解决方案1】:

    原来的WebView不包括滚动;如果你想要这种行为,你必须将它包装在一个 Flickable 中。来自the documentation

    WebView 项目包括无滚动、缩放、工具栏或其他 常见的浏览器组件。

    但正如您所指出的,将 WebView 1.0 包装在 Flickable 中是有问题的。在底层,WebKit 并不完全了解 Flickable 的滚动位置,因此任何依赖于该功能(固定定位、在 Javascript 中设置滚动位置等)的东西都无法开箱即用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-15
      • 2012-11-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多