資源簡介
1.進去server文件夾,在終端輸入"./server"啟動服務器程序
2.進入client文件夾,在終端輸入"./client"啟動客戶端程序,在連接服務器窗口可不必輸入端口號。(由于能力有限,未對ip地址的輸入格式作限制,希望你們能夠通過使用正則表達式來完善本程序)
聲明:本人精力有限,暫做到這,肯定還不完善,希望大家一起更正

代碼片段和文件信息
/****************************************************************************
**?Form?implementation?generated?from?reading?ui?file?‘chatform.ui‘
**
**?Created?by:?The?User?Interface?Compiler?($Id:?qt/main.cpp???3.3.8???edited?Jan?11?14:47?$)
**
**?WARNING!?All?changes?made?in?this?file?will?be?lost!
****************************************************************************/
#include?“chatform.h“
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#define?REMOTE_PORT?6789
#define?LOCAL_PORT??9875
typedef?struct?user
{
char?id[15];
char?ip[16];
}Friend;
Friend?friends[4];
int?num=-1;
/*
?*??Constructs?a?chatForm?as?a?child?of?‘parent‘?with?the
?*??name?‘name‘?and?widget?flags?set?to?‘f‘.
?*
?*??The?dialog?will?by?default?be?modeless?unless?you?set?‘modal‘?to
?*??TRUE?to?construct?a?modal?dialog.
?*/
chatForm::chatForm(?Socket?&sQWidget*?parent?const?char*?name?bool?modal?WFlags?fl?)
????:?QDialog(?parent?name?modal?fl?)sock(s)
{
????if?(?!name?)
setName(?“chatForm“?);
????tlable?=?new?QLabel(?this?“tlable“?);
????tlable->setGeometry(?QRect(?20?230?60?31?)?);
????sendBtn?=?new?QPushButton(?this?“sendBtn“?);
????sendBtn->setGeometry(?QRect(?230?371?60?30?)?);
????closeBtn?=?new?QPushButton(?this?“closeBtn“?);
????closeBtn->setGeometry(?QRect(?330?370?61?31?)?);
????chatTxt?=?new?QTextEdit(?this?“chatTxt“?);
????chatTxt->setGeometry(?QRect(?10?10?391?210?)?);
????chatTxt->setVScrollBarMode(?QTextEdit::AlwaysOn?);
????chatTxt->setHScrollBarMode(?QTextEdit::AlwaysOff?);
????editTxt?=?new?QTextEdit(?this?“editTxt“?);
????editTxt->setGeometry(?QRect(?10?270?391?90?)?);
????editTxt->setHScrollBarMode(?QTextEdit::AlwaysOff?);
????userlist?=?new?QComboBox(?FALSE?this?“userlist“?);
????userlist->setGeometry(?QRect(?80?230?131?31?)?);
????languageChange();
????resize(?QSize(418?402).expandedTo(minimumSizeHint())?);
????clearWState(?WState_Polished?);
????
????isChat=false;
?isToQuit=false;
?isQuited=false;
?
????//?signals?and?slots?connections
????//connect(?closeBtn?SIGNAL(?clicked()?)?this?SLOT(?close()?)?);
????connect(?closeBtn?SIGNAL(?clicked()?)?this?SLOT(?ToClose()?)?);
????connect(?closeBtn?SIGNAL(?clicked()?)?chatTxt?SLOT(?clear()?)?);
????connect(?this?SIGNAL(?IsQuit()?)?this?SLOT(?close()?)?);
????connect(?sendBtn?SIGNAL(?clicked()?)?this?SLOT(?ChatTo()));
????connect(thisSIGNAL(toGetUserList())thisSLOT(GetUserList()));
????connect(thisSIGNAL(toChat())thisSLOT(Chat()));
????
????connect(?sendBtn?SIGNAL(?clicked()?)?editTxt?SLOT(?clear()?)?);???
????connect(?sendBtn?SIGNAL(?clicked()?)?editTxt?SLOT(?setFocus()?)?);???
}
/*
?*??Destroys?the?object?and?frees?any?allocated?resources
?*/
chatForm::~chatForm()
{
????//?no?need?to?delete?child?widgets?Qt?does?it?all?for?us
}
/*
?*??Sets?the?strings?of?the?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????6161??2009-03-22?11:38??chatApp\client\chatform.cpp
?????文件???????6230??2009-03-22?11:34??chatApp\client\chatform.cpp~
?????文件???????1626??2009-03-18?20:57??chatApp\client\chatform.h
?????文件???????1604??2009-03-18?16:47??chatApp\client\chatform.h~
?????文件?????154392??2009-03-22?11:35??chatApp\client\chatform.o
?????文件?????645262??2009-03-22?11:35??chatApp\client\client
?????文件????????382??2009-03-17?21:02??chatApp\client\client.pro
?????文件??????24352??2009-03-17?21:36??chatApp\client\index.html
?????文件???????4566??2009-03-22?08:46??chatApp\client\li
?????文件???????4582??2009-03-13?15:58??chatApp\client\li
?????文件???????1441??2009-03-13?15:58??chatApp\client\li
?????文件???????1456??2009-03-13?15:58??chatApp\client\li
?????文件?????150256??2009-03-22?08:49??chatApp\client\li
?????文件???????5079??2009-03-13?15:58??chatApp\client\li
?????文件???????4721??2009-03-22?08:58??chatApp\client\loginForm.cpp
?????文件???????4718??2009-03-22?08:57??chatApp\client\loginForm.cpp~
?????文件???????1572??2009-03-22?08:47??chatApp\client\loginForm.h
?????文件???????1571??2009-03-17?17:52??chatApp\client\loginForm.h~
?????文件?????151796??2009-03-22?09:45??chatApp\client\loginForm.o
?????文件???????4660??2009-03-13?15:58??chatApp\client\loginForm.ui
?????文件????????269??2009-03-13?15:58??chatApp\client\main.cpp
?????文件????????352??2009-03-13?15:58??chatApp\client\main.cpp~
?????文件??????80672??2009-03-22?08:49??chatApp\client\main.o
?????文件???????4477??2009-03-17?21:02??chatApp\client\Makefile
?????文件???????4234??2009-03-18?21:00??chatApp\client\moc_chatform.cpp
?????文件?????189272??2009-03-18?21:00??chatApp\client\moc_chatform.o
?????文件???????4556??2009-03-13?15:58??chatApp\client\moc_li
?????文件?????189504??2009-03-22?08:49??chatApp\client\moc_li
?????文件???????4592??2009-03-22?08:49??chatApp\client\moc_loginForm.cpp
?????文件?????189492??2009-03-22?08:49??chatApp\client\moc_loginForm.o
............此處省略22個文件信息
- 上一篇:S3C2410芯片LED歷程
- 下一篇:CListCtrl的使用
評論
共有 條評論