Use the WebView API to make your own browser

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.