WebView QML 類

用於顯示 Web 內容的組件。 更多...

import 語句: import QtWebView 1.1

特性

信號

方法

詳細描述

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.

要使 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.

特性文檔編製

[read-only] canGoBack : bool

保持 true if it's currently possible to navigate back in the web history.

[read-only] canGoForward : bool

保持 true if it's currently possible to navigate forward in the web history.

[read-only] loadProgress : int

The current load progress of the web content, represented as an integer between 0 and 100.

[read-only] loading : bool

保持 true WebView is currently in the process of loading new content, false 否則。

另請參閱 loadingChanged() .

[read-only] 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.


信號文檔編製

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.

另請參閱 WebViewLoadRequest .


方法文檔編製

void goBack ()

Navigates back in the web history.

void goForward ()

Navigates forward in the web history.

void loadHtml ( string html , url baseUrl )

加載指定 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 .

void runJavaScript ( string script , variant callback )

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

void stop ()

停止加載當前 url .

版權所有  © 2014-2026 樂數軟件    

工業和信息化部: 粵ICP備14079481號-1