Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt QML-无法使用WebView显示javascript对话框_Qt_Webview_Qml_Qt Quick - Fatal编程技术网

Qt QML-无法使用WebView显示javascript对话框

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:

我有一个简单的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: 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中,该对话框未显示

有人能帮我找到问题吗? 谢谢