1 Star 2 Fork 5

Mky / QtChromeDemo

forked from 笨笨D幸福 / QtChromeDemo 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
index.html 1.41 KB
一键复制 编辑 原始数据 按行查看 历史
xin.zhang 提交于 2017-12-20 15:24 . 添加代码和readme
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>aaaa</title>
</head>
<body>
<p>Send msg</p>
<input id="input" value="i am msg from web/js" />
<button id="send">call cpp-a1</button>
<p>Recv msg</p>
<textarea id="output" readonly="readonly" cols=80 rows=10></textarea><br />
<script type="text/javascript" src="qrc:///qtwebchannel/qwebchannel.js"></script>
<script type="text/javascript">
function showmsg(message)
{
var output = document.getElementById("output");
output.innerHTML = output.innerHTML + message + "\n";
}
//Web initial loading
window.onload = function() {
showmsg("I am from web, call js func!");
new QWebChannel(qt.webChannelTransport, function(channel) {
//Get Qt interact object
var a1 = channel.objects.a1;
//Web send message to Qt
document.getElementById("send").onclick = function() {
var input = document.getElementById("input");
if (!input.value) {
return;
}
//Web use the interface of Qt
a1.t1(input.value);
}
//Web connect the Qt signal, then Qt can call "output" function
a1.sigNotify.connect(function(str) {
showmsg(str);
});
});
}
</script>
</body>
</html>
C++
1
https://gitee.com/52debug/QtChromeDemo.git
git@gitee.com:52debug/QtChromeDemo.git
52debug
QtChromeDemo
QtChromeDemo
master

搜索帮助