QML开发浏览器以及加载HTML5页面,主要利用QML的WebEngineView可实现对网页的加载。
其代码如下:
import QtQuick 2.4
import QtQuick.Layouts 1.2
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtWebEngine 1.1
Rectangle {
id: root
width: 800
height: 600
Rectangle {
id: edit_area
width: parent.width
height: 70
anchors {
left: parent.left
right: parent.right
}
color: "#E4EEF9"
Button {
id: goBack_click
anchors {
left: parent.left
leftMargin: 5
verticalCenter: edit_area.verticalCenter
}
width: 30
height: url_edit.height
property color bgColor: webView.canGoBack?"blue":"gray"
style: ButtonStyle {
background: Rectangle {
anchors.fill: parent