资源简介
此实用例子参考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程序
- 下一篇:计算机图形学实验报告
相关资源
- json读取(json.c)
- STM32三菱PLC源码原理图
- c++curllib传输json使用
- json-c 一个用于c语言的json解析库很强
- 将dataset json序列化和反序列化成data
- SpiderMonkey1.61.7 编译文件全部libdllh文件
- 百度地图二次开发汇总
- 任务栏托盘图标程序/MFC窗口定位/类似
- jsoncpp 三个工程编译成功 vs2015 x64
- PJSIP SIP协议栈C语言
- 两个对话框之间发送消息
- Dijskra算法 floyd算法
- VC+MFC 托盘图标闪烁与消息提示
- 百度OCR文字识别依赖库-libcurl、opens
- 自定义消息
- 自绘按钮的实现,对VC++6.0控件派生学
- json字符串转换c++类对象
- duilib中WebBrowser C++与js相互调用
- C++ 消息中间件MQ4CPP最新版源码
- VC++与JS交互源码——百度地图
- CEF 下C++与JS交互
- C++使用protobuf 作为网络消息协议
- PJSIP---可以视频通话的库 c++
-
MFC与Html、ja
vasc ript数据交互 -
Windows平台c++工程ba
se64与二进制文件 - 消息中间件应用开发:ActiveMQ实现单线
- c++调用dll,实现消息回调
- MFC中用CEF实现c++与js交互
- c语言利用RDMA 实现客户端和服务器端
- cocos2d-x C++ 版本 48款游戏集合 吐血共
评论
共有 条评论