国产探花免费观看_亚洲丰满少妇自慰呻吟_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"
    }
}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 锦屏县| 台山市| 普定县| 台山市| 霍山县| 台安县| 铜陵市| 台安县| 陇南市| 图木舒克市| 沿河| 揭阳市| 新疆| 冀州市| 友谊县| 三原县| 奉节县| 固阳县| 万载县| 古蔺县| 思茅市| 重庆市| 淳化县| 隆回县| 光泽县| 中西区| 鄄城县| 海安县| 普洱| 含山县| 湄潭县| 崇礼县| 盘锦市| 炉霍县| 潞城市| 吉水县| 仁寿县| 肇州县| 盐城市| 安吉县| 平顺县|