用于显示 Web 内容的组件。 更多...
import 语句: | import QtWebView |
(since QtWebView 1.14)
(since QtWebView 6.5)
(since QtWebView 6.3)
(since QtWebView 6.3)
(since QtWebView 6.3)
WebView is a component for displaying web content which is implemented using native APIs on the platforms where this is available, thus it does not necessarily require including a full web browser stack as part of the application.
To make the Qt WebView module function correctly across all platforms, it is necessary to call QtWebView::initialize () right after creating the QGuiApplication 实例。
注意: Due to platform limitations overlapping the WebView and other QML components is not supported.
canGoBack
:
bool
|
保持
true
if it's currently possible to navigate back in the web history.
canGoForward
:
bool
|
保持
true
if it's currently possible to navigate forward in the web history.
httpUserAgent
:
url
|
在使用中的用户代理。
注意: on WinRT, this property affects all WebViews of the application.
该特性在 QtWebView 1.14 引入。
loadProgress
:
int
|
The current load progress of the web content, represented as an integer between 0 and 100.
loading
:
bool
|
保持
true
若
WebView
is currently in the process of loading new content,
false
否则。
另请参阅 loadingChanged ().
settings
:
WebViewSettings
|
Settings object for the WebView .
This property was introduced in QtWebView 6.5.
另请参阅 WebViewSettings .
title
:
string
|
The title of the currently loaded web page.
url : url |
The URL of currently loaded web page. Changing this will trigger loading new content.
The URL is used as-is. URLs that originate from user input should be parsed with QUrl::fromUserInput ().
注意: The WebView does not support loading content through the Qt Resource system.
This signal is emitted when a cookie is added.
The parameters provide information about the domain 和 name of the added cookie.
注意: When Qt WebEngine module is used as backend, cookieAdded signal will be emitted for any cookie added to the underlying QWebEngineCookieStore , including those added by websites. In other cases cookieAdded signal is only emitted for cookies explicitly added with setCookie ().
注意:
相应处理程序是
onCookieAdded
.
This signal is emitted when a cookie is deleted.
The parameters provide information about the domain 和 name of the deleted cookie.
注意:
相应处理程序是
onCookieRemoved
.
loadingChanged ( WebViewLoadRequest loadRequest ) |
This signal is emitted when the state of loading the web content changes. By handling this signal it's possible, for example, to react to page load errors.
The loadRequest parameter holds the url and status of the request, as well as an errorString containing an error message for a failed request.
注意:
相应处理程序是
onLoadingChanged
.
另请参阅 WebViewLoadRequest .
|
Deletes all the cookies.
This method was introduced in QtWebView 6.3.
|
Deletes a cookie with the specified domain and name .
The cookieRemoved signal will be emitted when the cookie is deleted.
This method was introduced in QtWebView 6.3.
void goBack () |
Navigates back in the web history.
void goForward () |
Navigates forward in the web history.
加载指定 html content to the web view.
This method offers a lower-level alternative to the url property, which references HTML pages via URL.
External objects such as stylesheets or images referenced in the HTML document should be located relative to
baseUrl
. For example, if
html
检索自
http://www.example.com/documents/overview.html
, which is the base URL, then an image referenced with the relative url,
diagram.png
,应该在
http://www.example.com/documents/diagram.png
.
注意: The WebView does not support loading content through the Qt Resource system.
另请参阅 url .
void reload () |
重新加载当前 url .
Runs the specified JavaScript. In case a callback function is provided, it will be invoked after the script finished running.
runJavaScript("document.title", function(result) { console.log(result); });
|
Adds a cookie with the specified domain , name and value .
The cookieAdded signal will be emitted when the cookie is added.
This method was introduced in QtWebView 6.3.
void stop () |
停止加载当前 url .