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



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.