Qt WebView

Qt WebView 提供在 QML 應用程序中顯示 Web 內容的方式,而不必通過使用有意義的本機 API 來包括完整 Web 瀏覽器堆棧。

這在移動平颱是有用的,譬如: Android , iOS ,和 UWP (通用 Windows 平颱) ;尤其在 iOS,策略規定所有 Web 內容均使用操作係統的 Web 視圖顯示。

On Windows and Linux, Qt WebView depends on the Qt WebEngine 模塊渲染內容。

On macOS, the system web view is used in the same manner as iOS.

先決條件

要使 Qt WebView 模塊函數正確跨所有平颱,有必要調用 QtWebView::initialize () 之後纔創建 QGuiApplication 實例和在創建窗口的 QPlatformOpenGLContext 之前。

QML 類型

模塊提供在應用程序中顯示 Web 內容的單 QML 組件: WebView .

局限性

由於平颱的限製,重疊 WebView 與其它 QML 組件不被支持。這樣做會産生不可預測結果,可能因平颱而異。

平颱注意事項

\secion2 Android

From API level 30 the native Android WebView will have file access disabled by default. Since there are no APIs in QtWebView to override the file access property, the two environment variables QT5_ANDROID_WEBVIEW_ALLOW_FILE_ACCESS and QT5_ANDROID_WEBVIEW_ALLOW_FILE_ACCESS_FROM_URLS are provided which, when set, re-enables file access support again.

範例

查看 Qt WebView 範例 瞭解如何在應用程序中使用 API 的演示。

許可

Qt WebView 在商業許可下是可用的來自 Qt 公司 。此外,它是可用的根據 GNU LGPL (次一般公共許可) 第 3 版 ,或 GNU GPL (一般公共許可) 第 2 版 。見 Qt 許可 進一步瞭解細節。

API 參考