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.0import ubuntu.components 1.1import ubuntu.web 0.2import 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 ("") Row Layout {id:toolbar anchors.top:parent.top width:parent.width height:units. Gu (8) spacing:units.gu (1) Icon {id:back Anchors.verticalCenter:par Ent.verticalcenteR name: "Go-previous" Height:input.height width:height visib Le:webview.canGoBack Mousearea {anchors.fill:parent onclicked:web View.goback (); }} Icon {Id:forward anchors.verticalCenter:parent.verticalCenter Name: "Go-next" Height:input.height width:height visible:web View.cangoforward Mousearea {anchors.fill:parent Onclicked:webview . GoForward (); }} TextField {Id:input anchors.verticalCenter:parent.verticalCente R Height:parent.height-units.gu (1) Layout.maximumWidth:parent.width layou T.preferredwidth:parent.width-back.width-forward.width text: "http:Www.baidu.com "onaccepted: {webview.url = Input.text}} } WebView {Id:webview anchors.top:toolbar.bottom height:parent.height-t Oolbar.height width:parent.width 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 for the entire project is: Git clone https://gitcafe.com/ubuntu/browser.git
Use the WebView API to make your own browser