We can see that there is a webview in the Ubuntu SDK. It does not use the QT standard WebKit library. On Ubuntu, we have done a lot of optimization (oxide engine) on the following engine, which makes our webview performance more superior.
Let's use an example to design a simple browser.
Import QtQuick 2.0 Import ubuntu.components 1.1 import ubuntu.web 0.2 import qtquick.layouts 1.1/*!
\brief MainView with a Label and Button elements. */MainView {//ObjectName for functional testing purposes (AUTOPILOT-QT5) ObjectName: "MainView"//note!
ApplicationName needs to match the "name" field of the click Manifest ApplicationName: "Browser.liu-xiao-guo"/* The enables the application to change orientation when the device is rotated.
The default is False.
*///automaticorientation:true//Removes the old toolbar and enables new features of the new header.
Usedeprecatedtoolbar:false Width:units.gu (Height:units.gu) Page {title:i18n.tr ("") rowlayout {Id:toolbar Anchors.top:parent.top width:parent.width he Ight:units.gu (8) Spacing:units.gu (1) Icon {id:back AnchOrs.verticalCenter:parent.verticalCenter Name: "Go-previous" height:input.height Width:height visible:webview.canGoBack Mousearea {Anchors
. Fill:parent OnClicked:webview.goBack (); }} Icon {Id:forward anchors.verticalCenter:parent.verticalCent ER name: "go-next" Height:input.height width:height Visi Ble:webview.canGoForward Mousearea {anchors.fill:parent OnClick
Ed:webview.goForward (); }} TextField {Id:input anchors.verticalCenter:parent.vertical
Center Height:parent.height-units.gu (1) Layout.maximumWidth:parent.width Layout.preferredwidth:Parent.width-back.width-forward.width text: "Http://www.baidu.com" onaccepted: { Webview.url = Input.text}}} webview {ID:WEBV Iew Anchors.top:toolbar.bottom height:parent.height-toolbar.height WIDTH:PARENT.W
Idth URL: "Http://www.baidu.com"}}}
Here we have used:
Import Ubuntu.web 0.2
Module. On top of that we used two icons to go back or forward. At the same time we designed a TextField to enter the address we want to go to. Note that the address must be a string that begins with HTTP. When we press the ENTER key, we open the page ourselves.
The code is not much, but it accomplishes what we want to accomplish.
The source code of the whole project is: Https://github.com/liu-xiao-guo/browser