资源简介
此实用例子参考QT代码示例,经过自己改编及测试:实现了C++与JS的相互调用及发送消息。
代码片段和文件信息
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the demonstration applications of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or alternatively in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1 included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include “document.h“
void Document::setSendTextText(const QString &text)
{
s_text = text;
emit sendText(s_text);
}
void Document::displayMessage(const QString &message)
{
mainUi->editor->appendPlainText(message);
}
/*!
This slot is invoked from the HTML client side and the text displayed on the server side.
*/
void Document::receiveText(const QString &r_text)
{
displayMessage(Qobject::tr(“Received message: %1“).arg(r_text));
}
void Document::setUi(Ui::MainWidget *ui)
{
mainUi = ui;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2483 2016-01-12 09:13 document.cpp
文件 2640 2016-01-12 09:12 document.h
文件 421 2016-01-12 02:04 htmlpage.cpp
文件 2164 2016-01-12 08:01 index.html
文件 206 2016-01-12 03:13 main.cpp
文件 1015 2017-10-10 09:37 mainwidget.cpp
文件 513 2016-01-12 09:01 mainwidget.h
文件 2129 2016-01-12 07:58 mainwidget.ui
文件 24491 2016-01-12 03:25 Makefile
文件 78909 2016-01-12 03:25 Makefile.Debug
文件 78942 2016-01-12 03:25 Makefile.Release
文件 2378 2017-10-09 13:29 previewpage.cpp
文件 2309 2015-12-14 10:27 previewpage.h
文件 14837 2015-12-14 10:27 qwebchannel.js
文件 4578 2016-01-12 08:33 ui_mainwidget.h
文件 530 2016-01-12 03:24 webchanneltest.pro
文件 23945 2017-10-11 19:46 webchanneltest.pro.user
文件 23422 2016-01-12 09:14 webchanneltest.pro.user.e55cfe6
文件 131 2016-01-12 01:32 webchanneltest.qrc
- 上一篇:M/M/1 排队论C程序
- 下一篇:计算机图形学实验报告
相关资源
- VC通过HttpGet和HttpPost方式与WebService通
- Dijstra和Floyd算法
- VC++6.0下编译通过JSONjsoncpp-src-0.5.0
- 中国移动通信CMPP2.0短消息网关开发接
- C++ mysql查询 C++17编写 可以自动序列化
- jsonrpc c++ 基于boost:asio
- STM32F103下CJSON库使用举例(cJSONtest.c)
- jsoncpp-0.y.z 代码
- 基于pjsip的c
- sip.js demo(freeswitch)
- C++实战源码-利用消息断点进行程序调
- CocosCreator js 麻将
- C语言JSON解析(Exjson)
- C++ 自定义消息
- C++ 注册消息
- C++ 发送WM_COPYDATA消息
- c++ 串口 发送消息、接收消息源代码(
- C语言cJSON库的使用解析json数据格式
- mosquitto 消息推送协议MQTT 源码分析
- Json 的C语言实现
- TCP消息转发服务器
- MFC 消息对话框 入门级
-
ja
vasc ript实现的CRC16源码非查表法 - C语言实现的 json格式字符串与结构体
- QT5.9 利用 QWebEngineView / QWebChannel 调用
- mq4cpp_v1.16.zip 一个基于C/C++的消息中间
- C语言实现ota升级代码
- C++,UDP通信类,方便实现基于消息或
- CWebPage类和MFC结合调用JS函数的
- json-rpc协议C语言版
评论
共有 条评论