• 大小: 582KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-29
  • 语言: 其他
  • 标签: linux  

资源简介

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\linkForm.cpp

     文件       4582  2009-03-13 15:58  chatApp\client\linkForm.cpp~

     文件       1441  2009-03-13 15:58  chatApp\client\linkForm.h

     文件       1456  2009-03-13 15:58  chatApp\client\linkForm.h~

     文件     150256  2009-03-22 08:49  chatApp\client\linkForm.o

     文件       5079  2009-03-13 15:58  chatApp\client\linkForm.ui

     文件       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_linkForm.cpp

     文件     189504  2009-03-22 08:49  chatApp\client\moc_linkForm.o

     文件       4592  2009-03-22 08:49  chatApp\client\moc_loginForm.cpp

     文件     189492  2009-03-22 08:49  chatApp\client\moc_loginForm.o

............此处省略22个文件信息

评论

共有 条评论