国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > WEB開發 > 正文

QML做Android的瀏覽器Demo

2024-04-27 15:13:57
字體:
來源:轉載
供稿:網友

由于目前Qt的webenginewidgets對Android還不支持,這里只能用QML的webview。

①、在PRo中添加:QT += webview

②、引用頭文件import QtWebView 1.1(注意,由于只適用于Android,所以Qt沒做補全功能)

③、直接用就可以了:    

WebView {

   anchors.fill: parent

   url: "http://www.baidu.com" 

}

這樣就可以用了,是不是很簡單嘞?

以下是我做的小樣,可以參考:

import QtQuick 2.6
import QtQuick.Window 2.2
import QtWebView 1.1
Window {
    visible: true
    property int tmpHei: width > height ? height/8.0 :height/16.0
    Rectangle{
        id:title
        x:0
        y:0
        width: parent.width - tmpHei
        height: tmpHei
        color: "yellow"
        TextInput {
            id:textInput
            anchors.verticalCenter: parent.verticalCenter
            anchors.left: title.left
            font.pixelSize: tmpHei/2
            text: qsTr("http://www.baidu.com")
            color: "red"
        }
    }
    Rectangle {
        id:btn
        y:0
        anchors.left: title.right
        width: tmpHei
        height: tmpHei
        color: "black"
        Text {
            anchors.centerIn: parent
            font.pixelSize: tmpHei/2
            text: qsTr("Go")
            color: "white"
        }
        MouseArea{
            anchors.fill: parent
            onClicked: {
                webView.url = "http://" + textInput.text
            }
        }
    }
    WebView {
        id:webView
        x:0
        anchors.top: title.bottom
        width: parent.width
        height: parent.height - tmpHei
        url: "http://www.baidu.com"
    }
}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 子洲县| 昭平县| 稷山县| 巍山| 四川省| 民和| 永平县| 马边| 车险| 宁夏| 玉溪市| 英吉沙县| 菏泽市| 砀山县| 定州市| 隆子县| 平顶山市| 个旧市| 会东县| 溧水县| 江口县| 西乌| 崇仁县| 林周县| 南华县| 澄江县| 兴文县| 大同县| 中方县| 阆中市| 腾冲县| 连城县| 淳安县| 芮城县| 岳阳市| 图们市| 磐石市| 霍邱县| 静安区| 忻州市| 台东县|