基于qt编写的c/s模型的简单聊天程序

基于qt编写的c/s模型的简单聊天程序

ID:11766028

大小:49.00 KB

页数:7页

时间:2018-07-13

基于qt编写的c/s模型的简单聊天程序_第1页
基于qt编写的c/s模型的简单聊天程序_第2页
基于qt编写的c/s模型的简单聊天程序_第3页
基于qt编写的c/s模型的简单聊天程序_第4页
基于qt编写的c/s模型的简单聊天程序_第5页
资源描述:

《基于qt编写的c/s模型的简单聊天程序》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、基于qt编写的c/s模型的简单聊天程序(借鉴别人的)2009-06-2711:29/*程序预览*/部分源码:/*login.cpp*/#include"login.h"LoginDialog::LoginDialog(){   setupUi(this);   connect(awayButton,SIGNAL(clicked()),qApp,SLOT(quit()));   connect(enterButton,SIGNAL(clicked()),this,SLOT(enterSlot()));}voidLoginDialog::enterSlot(){      

2、if(lineEdit_2->text().isEmpty())   {      QMessageBoxmess;      mess.setFont(QFont("SansSerif",12,50));      mess.warning(this,                QString::fromLocal8Bit("出错"),                QString::fromLocal8Bit("请输入正确的昵称,谢谢!"));         return;   }   emitsendEnterMessa

3、ge(lineEdit_2->text(),lineEdit_3->text());   emitshowChatWindow();}voidLoginDialog::closeEvent(QCloseEvent*){   qApp->quit();}/*chat.cpp*/#include"chat.h"Chat::Chat(){   serverSocket=NULL;   server=NULL;   client=NULL;       setupUi(this);   login=newLoginDialog;   login->show();   conne

4、ct(login,SIGNAL(showChatWindow()),this,SLOT(showAndHideSlot()));      connect(login,SIGNAL(sendEnterMessage(QString,QString)),   this,SLOT(enterSlot(QString,QString)));      connect(writeMessageEdit,SIGNAL(textChanged()),this,SLOT(changeButtonStateSlot()));         connect(aboutButton,SI

5、GNAL(clicked()),this,SLOT(createAboutSlot()));      connect(sendButton,SIGNAL(clicked()),this,SLOT(appendMessageSlot()));      connect(quitButton,SIGNAL(clicked()),qApp,SLOT(quit()));}voidChat::showAndHideSlot(){   deletelogin;   this->show();}voidChat::createAboutSlot(){}voidChat::enter

6、Slot(QStringname,QStringhost){    port=22222;         if(host.isEmpty())    {        socketServer();    }    else    {        socketClient(host);    }        userName=name;   onlineMessageList->addItem(name);}voidChat::changeButtonStateSlot(){   boolboo_dis=writeMessageEdit->toPlainText(

7、).isEmpty();   sendButton->setDisabled(boo_dis);}voidChat::appendMessageSlot(){   QStringcontent=writeMessageEdit->toPlainText();   if(content.isEmpty())   {      QMessageBox::warning(this,"出错",QString::fromLocal8Bit("发送的内容不能为空"));      return;   }   nowDateTime=QDateTime

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。