資源簡介
Qt實現(xiàn)微信氣泡聊天效果,這里只是做了一個Demo,可以發(fā)送消息,消息撤回使用QWebChannl HTML與Qt通信,取出撤回的消息序號,從而撤回消息。https://blog.csdn.net/qq_25532071/article/details/88427192文章中有效果及詳細介紹

代碼片段和文件信息
#include?“cos_groupchat.h“
#include?
#include?
#include?
//#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
Cos_GroupChat::Cos_GroupChat(QWidget?*parent)
????:?QDialog(parent)?sendDivID(0)?RecvDIvID(0)
{
????ui.setupUi(this);
????this->setMinimumWidth(250);
????this->setWindowtitle(“DDLT“);
????//this->setWindowIcon
????//設置我方頭像和對方頭像
????Myhead?=?“
“;
????QString?strHead?=?QString(“qrc:/resource/otherHead.png“);
????otherhead?=?QString(“
“).arg(strHead);
????m_pView?=?new?QWebEngineView(this);
????m_pView->installEventFilter(this);
????ui.m_textEdit_send->installEventFilter(this);
????//m_pView->setContextMenuPolicy(Qt::NoContextMenu);?//禁用右擊
????//m_pView->setstyleSheet(“background-color:#ffffff“);
????QWebEnginePage?*pPage?=?new?QWebEnginePage(this);
????m_pView->setPage(pPage);
????Document*??m_content?=?new?Document(this);
????QWebChannel?*channel?=?new?QWebChannel(this);
????channel->registerobject(QStringLiteral(“contentObj“)?m_content);
????pPage->setWebChannel(channel);
????//加載HTML模板
????m_pView->page()->load(QUrl(“qrc:/resource/messageBox.html“));
????QVBoxLayout?*pMai?=?new?QVBoxLayout;
????pMai->addWidget(m_pView);
????pMai->setContentsMargins(0?0?0?0);
????ui.m_pframe->setLayout(pMai);
???pManager?=?new?Cos_TcpConnectManger;
????QNetworkProxyFactory::setUseSystemConfiguration(false);
????connect(ui.m_Btn_Send?SIGNAL(clicked())?this?SLOT(slot_lineEditReturnpressed()));
????connect(pManager?SIGNAL(sig_receiveMessage(QString?))?this?SLOT(slot_receiveMessage(QString)));
????connect(m_content?SIGNAL(sig_deleteMesssage(QString?))?this?SLOT(slot_receiveMessage(QString)));
????//接收到服務器發(fā)送過的消息連接槽
}
Cos_GroupChat::~Cos_GroupChat()
{
}
void?Cos_GroupChat::ppppp()
{
????QString?pHtml?=?pTextEdit1->toPlainText();
????QString?html?=?QString(“appendMyMessage(%1?‘%2‘);scrollBottom();“).arg(“‘you‘“).arg(pHtml);
????m_pView->page()->runjavascript(html);
}
void?Cos_GroupChat::ppppp1()
{
????QString?pHtml?=?pTextEdit2->toPlainText();
????qDebug()?<????QString?html?=?QString(“appendOtherMessage(%1?‘%2‘);scrollBottom();“).arg(“‘me‘“).arg(pHtml);
????m_pView->page()->runjavascript(html);
}
bool?Cos_GroupChat::eventFilter(Qobject?*watched?QEvent?*event)
{
????if?(watched?==?m_pView)
????{
????????QWheelEvent?*p?=?dynamic_cast(event);
????????if?(p)
????????{
????????????return?QWidget::eventFilter(watched?event);
????????}
????}
????else?if?(watched?==?ui.m_textEdit_send)
????{
????????if?(event->type()?==?QEvent::KeyPress)?{
????????????QKeyEve
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1026??2019-02-12?11:01??Cos_GroupChat\.qmake.stash
?????文件???????1571??2015-08-04?23:07??Cos_GroupChat\00393_24x24x8BPP_.gif
?????文件???????6783??2016-09-02?14:04??Cos_GroupChat\1.jpg
?????文件???????7258??2019-03-12?19:05??Cos_GroupChat\cos_groupchat.cpp
?????文件???????1466??2019-02-15?17:40??Cos_GroupChat\cos_groupchat.h
?????文件???????1310??2019-02-15?17:35??Cos_GroupChat\Cos_GroupChat.pro
?????文件??????23850??2019-02-18?16:20??Cos_GroupChat\Cos_GroupChat.pro.user
?????文件???????3954??2019-02-15?17:34??Cos_GroupChat\cos_groupchat.ui
?????文件????????241??2019-02-12?11:32??Cos_GroupChat\cos_groupresouce.qrc
?????文件???????2013??2019-02-12?16:51??Cos_GroupChat\cos_tcpconnectmanger.cpp
?????文件????????956??2019-02-12?14:47??Cos_GroupChat\cos_tcpconnectmanger.h
?????文件?????177152??2019-03-12?19:10??Cos_GroupChat\debug\Cos_GroupChat.exe
?????文件????2084976??2019-03-12?19:10??Cos_GroupChat\debug\Cos_GroupChat.ilk
?????文件?????357869??2019-03-12?19:07??Cos_GroupChat\debug\cos_groupchat.obj
?????文件????3379200??2019-03-12?19:10??Cos_GroupChat\debug\Cos_GroupChat.pdb
?????文件????2437120??2019-03-12?19:10??Cos_GroupChat\debug\Cos_GroupChat.vc.pdb
?????文件?????106676??2019-02-18?10:15??Cos_GroupChat\debug\cos_tcpconnectmanger.obj
?????文件??????56324??2019-02-18?10:15??Cos_GroupChat\debug\document.obj
?????文件??????????0??2019-02-18?11:56??Cos_GroupChat\debug\log.txt
?????文件??????74423??2019-02-18?10:15??Cos_GroupChat\debug\main.obj
?????文件???????6276??2019-02-18?10:15??Cos_GroupChat\debug\moc_cos_groupchat.cpp
?????文件?????143636??2019-02-18?10:15??Cos_GroupChat\debug\moc_cos_groupchat.obj
?????文件???????7232??2019-02-18?10:15??Cos_GroupChat\debug\moc_cos_tcpconnectmanger.cpp
?????文件??????78549??2019-02-18?10:15??Cos_GroupChat\debug\moc_cos_tcpconnectmanger.obj
?????文件???????7096??2019-02-18?10:15??Cos_GroupChat\debug\moc_document.cpp
?????文件??????60614??2019-02-18?10:15??Cos_GroupChat\debug\moc_document.obj
?????文件????????260??2019-02-18?10:15??Cos_GroupChat\debug\moc_predefs.h
?????文件???????3485??2019-02-18?10:15??Cos_GroupChat\debug\moc_testdialog.cpp
?????文件??????66757??2019-02-18?10:15??Cos_GroupChat\debug\moc_testdialog.obj
?????文件?????102912??2019-03-12?19:10??Cos_GroupChat\debug\qrc_cos_groupresouce.cpp
............此處省略23個文件信息
評論
共有 條評論