Qt QML-无法使用WebView显示javascript对话框
我有一个简单的QML代码,一个简单的HTML代码和一些javascript,我不知道如何在我的javascript中显示对话框 这是我的QML代码:Qt QML-无法使用WebView显示javascript对话框,qt,webview,qml,qt-quick,Qt,Webview,Qml,Qt Quick,我有一个简单的QML代码,一个简单的HTML代码和一些javascript,我不知道如何在我的javascript中显示对话框 这是我的QML代码: import QtQuick 2.0 import QtWebKit 3.0 Rectangle { width: 1280 height: 720 color:"#ff000000" WebView { id: webView anchors.centerIn:
import QtQuick 2.0
import QtWebKit 3.0
Rectangle {
width: 1280
height: 720
color:"#ff000000"
WebView {
id: webView
anchors.centerIn: parent
anchors.fill: parent
url: "index.html"
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>index</title>
</head>
<body>
<button onclick="testAlert();">Button</button>
<script type="text/javascript">
function testAlert()
{
alert("test");
}
</script>
</body>
</html>
这是我的index.html代码:
import QtQuick 2.0
import QtWebKit 3.0
Rectangle {
width: 1280
height: 720
color:"#ff000000"
WebView {
id: webView
anchors.centerIn: parent
anchors.fill: parent
url: "index.html"
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>index</title>
</head>
<body>
<button onclick="testAlert();">Button</button>
<script type="text/javascript">
function testAlert()
{
alert("test");
}
</script>
</body>
</html>
指数
按钮
函数testAlert()
{
警报(“测试”);
}
在普通的web浏览器中,此html代码正在工作并向我显示一个对话框。在QML WebView中,该对话框未显示
有人能帮我找到问题吗?
谢谢