-
大小: 254KB文件類型: .rar金幣: 2下載: 0 次發(fā)布日期: 2021-06-09
- 語言: 其他
- 標簽:
資源簡介

代碼片段和文件信息
/********************************************************************************
*?File?Name: chatwidgit.cpp
*?Description: 第15章實例訓練
*?Reference?book:《Linux環(huán)境下Qt4圖形界面與MySQL編程》,機械工業(yè)出版社.2012.1
*?E_mail:?openlinux2011@gmail.com
*
********************************************************************************/
#include?“chatwidgit.h“
#include?“ui_chatwidgit.h“
//此函數(shù)是網(wǎng)上的??將html格式的qstring?轉(zhuǎn)換
QString?simplifyRichText(?QString?f_richText?)
{
????QRegExp?rxBody(“]*>(.*)“);
????if(rxBody.indexIn(f_richText))
????{
????????f_richText?=?rxBody.cap(1);?//?throw?away?anything?not?in?the?body?and?the?body?tags?as?well
????????f_richText.replace(QRegExp(“^\\s+“)““);?//?throw?away?any?leading?whitespace?(be?it?new?lines?or?spaces)
????}
????QRegExp?rxBody1(“]*>(.*)“);
????if(f_richText.indexOf(rxBody1)?!=?-1){
????????if(rxBody1.indexIn(f_richText))
????????{
????????????f_richText?=?rxBody1.cap(1);?//?throw?away?anything?not?in?the?body?and?the?body?tags?as?well
????????????f_richText.replace(QRegExp(“^\\s+“)““);?//?throw?away?any?leading?whitespace?(be?it?new?lines?or?spaces)
????????}
????}
????f_richText.replace(QRegExp(“yle=\“[^\“]*\“>“)“
“);?//?throw?away?paragraph?styles
????if(f_richText?==?““)?//?thats?what?we?get?for?an?empty?QTextEdit
????????return?QString();
????f_richText.replace(““““);
????f_richText.replace(“
“““);
????return?f_richText;
}
//初始化????連接編輯框?和字體裝換的信號與槽??設(shè)置位置。。
ChatWidgit::ChatWidgit(QWidget?*parent)?:
????????QWidget(parent)
????????ui(new?Ui::ChatWidgit)
{
????ui->setupUi(this);
????ui->tbHistory->hide();
????ui->teEdit->setFocusPolicy(Qt::StrongFocus);
????ui->teEdit->setFocus();
????ui->teEdit->installEventFilter(this);
????this->resize(500400);
????connect(ui->teEditSIGNAL(currentCharFormatChanged(QTextCharFormat))thisSLOT(currentFormatChanged(const?QTextCharFormat)));
}
//析構(gòu)
ChatWidgit::~ChatWidgit()
{
????delete?ui;
}
//收到主窗體發(fā)來的聊天消息??對比是否是此聊天框接收??并將聊天記錄儲存?顯示
void?ChatWidgit::setMessage(QString?address?QString?first?QString?second)
{
????if(address?==?secretAddress?){
????????ui->tbShow->setTextColor(Qt::blue);
????????ui->tbShow->setCurrentFont(QFont(“Times?New?Roman“12));
????????ui->tbShow->append(first);
????????ui->tbShow->append(second);
????????//????????QMessageBox::information(thistr(“a“)tr(“%1\n%2“).arg(first).arg(second));
????????if(!saveFile.open(QFile::WriteOnly?|?QFile::Text?|?QFile::Append))
????????{
????????????QMessageBox::warning(thistr(“保存文件“)
?????????????????????????????????tr(“無法保存文件?:\n?%1“).arg(saveFile.errorString()));
????????????return;
????????}
????????QTextStream?out(&saveFile);
????????out?<
????????//????????out?<
????????saveFile.close();
????}
}
//獲取本機ip
QString?ChatWidgit::getIP()??//獲取ip地址
{
????QList?list?=?QNetworkInterface::allAddresses();
????foreach?(QHostAddress?address?list)
????{
??
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????9062??2011-12-28?15:21??基于QT的局域網(wǎng)聊天系統(tǒng)\chatwidgit.cpp
?????文件???????1712??2011-12-28?15:21??基于QT的局域網(wǎng)聊天系統(tǒng)\chatwidgit.h
?????文件??????10058??2011-11-10?10:37??基于QT的局域網(wǎng)聊天系統(tǒng)\chatwidgit.ui
?????文件????????736??2011-11-04?12:40??基于QT的局域網(wǎng)聊天系統(tǒng)\ClientAp.pro
?????文件???????8001??2011-12-28?15:21??基于QT的局域網(wǎng)聊天系統(tǒng)\ClientAp.pro.user
?????文件????????780??2011-12-28?15:21??基于QT的局域網(wǎng)聊天系統(tǒng)\databa
?????文件????????563??2011-12-28?15:21??基于QT的局域網(wǎng)聊天系統(tǒng)\databa
?????文件???????4120??2011-12-28?15:21??基于QT的局域網(wǎng)聊天系統(tǒng)\filereceiver.cpp
?????文件???????1440??2011-12-28?15:21??基于QT的局域網(wǎng)聊天系統(tǒng)\filereceiver.h
?????文件???????1781??2011-11-10?10:37??基于QT的局域網(wǎng)聊天系統(tǒng)\filereceiver.ui
?????文件???????4609??2011-12-28?15:21??基于QT的局域網(wǎng)聊天系統(tǒng)\filesender.cpp
?????文件???????1392??2011-12-28?15:21??基于QT的局域網(wǎng)聊天系統(tǒng)\filesender.h
?????文件???????1486??2011-11-06?10:45??基于QT的局域網(wǎng)聊天系統(tǒng)\filesender.ui
?????文件?????161862??2005-02-20?12:18??基于QT的局域網(wǎng)聊天系統(tǒng)\ico\myicon.ico
?????文件?????????46??2011-04-11?21:40??基于QT的局域網(wǎng)聊天系統(tǒng)\icon.rc
?????文件??????10861??2010-04-07?21:34??基于QT的局域網(wǎng)聊天系統(tǒng)\image\20091201_0c5e3cb96bf053f6f8f43xlWxvBTLEnr.png
?????文件??????12548??2010-04-07?21:33??基于QT的局域網(wǎng)聊天系統(tǒng)\image\20091201_2a0f6976569659175fd3PEFlPFnrDS1R.png
?????文件???????9497??2010-04-07?21:34??基于QT的局域網(wǎng)聊天系統(tǒng)\image\20091201_b321df1d9e60373380a0IQzepnVIU3HS.png
?????文件???????8608??2010-04-07?21:35??基于QT的局域網(wǎng)聊天系統(tǒng)\image\20091201_e59eb6d747cef0b2bc89nKJwRb2QIxXh.png
?????文件??????19201??2005-02-15?20:50??基于QT的局域網(wǎng)聊天系統(tǒng)\image\Bin?(empty).png
?????文件????????813??2011-04-11?16:25??基于QT的局域網(wǎng)聊天系統(tǒng)\image\chatHis.png
?????文件??????16155??2005-02-16?21:16??基于QT的局域網(wǎng)聊天系統(tǒng)\image\E-Mail.png
?????文件???????2168??2010-02-11?23:55??基于QT的局域網(wǎng)聊天系統(tǒng)\image\fileopen.png
?????文件???????3200??2005-02-15?17:38??基于QT的局域網(wǎng)聊天系統(tǒng)\image\Files.png
?????文件???????9576??2005-02-21?19:29??基于QT的局域網(wǎng)聊天系統(tǒng)\image\Floppy.png
?????文件??????22074??2005-02-20?12:28??基于QT的局域網(wǎng)聊天系統(tǒng)\image\MSN-Messenger.png
?????文件???????1928??2006-04-14?18:06??基于QT的局域網(wǎng)聊天系統(tǒng)\image\textbold.png
?????文件???????4226??2005-10-05?21:37??基于QT的局域網(wǎng)聊天系統(tǒng)\image\textcolor.png
?????文件???????1164??2010-02-11?23:55??基于QT的局域網(wǎng)聊天系統(tǒng)\image\textitalic.png
?????文件???????1644??2006-04-14?18:06??基于QT的局域網(wǎng)聊天系統(tǒng)\image\textunder.png
............此處省略19個文件信息
評論
共有 條評論