Consider the following QML snippet:
Page {
WebView {
id: webView
anchors.fill: parent
}
}
I then attempt to load some HTML in the WebView using the following JavaScript:
webView.loadHtml('<b>test</b>');
However, the WebView has a white background:
(Ignore the fact that the text is too small.)
Is there a way to make the background transparent?
You could try QtWebKit.experimental. If you add import QtWebKit.experimental 1.0 to your QML files, your WebView objects will have access to experimental attributes:
import QtQuick 2.0
import QtWebKit.experimental 1.0
import Ubuntu.Components 0.1
MainView {
id: main
width: units.gu(100)
height: units.gu(75)
Page {
id: mypage
Rectangle {
color: "green"
anchors.fill: mypage
WebView {
id: webView
anchors.fill: parent
experimental.transparentBackground: true
}
}
Component.onCompleted: webView.loadHtml("<p>Hello</p>");
}
}
Obviously you'll get this kind of warning:
WARNING: The experimental API will change from version to version, or even be removed. You have been warned!
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다