chat::chat(QString pasvusername, QString pasvuserip) : ui(new Ui::chat) { ui->setupUi(this); ui->textEdit->setFocusPolicy(Qt::StrongFocus); ui->textBrowser->setFocusPolicy(Qt::NoFocus); ui->textEdit->setFocus(); ui->textEdit->installEventFilter(this); a = 0; is_opened = false; // this->is_opened = false; xpasvusername = pasvusername; xpasvuserip = pasvuserip; ui->label->setText(tr("与%1聊天中 对方IP:%2").arg(xpasvusername).arg(pasvuserip)); //UDP部分 xchat = new QUdpSocket(this); xport = 45456; // xchat->bind(xport, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); xchat->bind( QHostAddress(getIP()), xport ); connect(xchat, SIGNAL(readyRead()), this, SLOT(processPendingDatagrams())); //TCP部分 server = new TcpServer(this); connect(server,SIGNAL(sendFileName(QString)),this,SLOT(sentFileName(QString))); connect(ui->textEdit,SIGNAL(currentCharFormatChanged(QTextCharFormat)),this,SLOT(currentFormatChanged(const QTextCharFormat))); }
chat::chat(QString pasvusername,QString pasvuserip): ui(new Ui::chat) { ui->setupUi(this); ui->textEdit->setFocusPolicy(Qt::StrongFocus); ui->textBrowser->setFocusPolicy(Qt::NoFocus); ui->textEdit->setFocus(); ui->textEdit->installEventFilter(this); ui->send->setStyleSheet(tr("QPushButton{ border:0px;border-radius:5px;color:white;background-color:rgb(172, 213, 191)}QPushButton:hover{background-color:rgb(153, 186, 255);}QPushButton:pressed{background-color:rgb(153, 186, 255);}")); //退出按钮 ui->close->setStyleSheet(tr("QPushButton{border:0px;border-radius:5px;color:white;background-color:rgb(195, 195, 195);}QPushButton:hover{background-color:#505050;}QPushButton:pressed{background-color:#505050;}")); a = 0; is_opened = false; // this->is_opened = false; xpasvusername = pasvusername; xpasvuserip = pasvuserip; ui->label->setText(tr("与%1聊天中 对方IP:%2").arg(xpasvusername).arg(pasvuserip)); //UDP部分 xchat = new QUdpSocket(this); xport=6900; // xchat->bind(xport, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); QHostAddress chat_me(getIP()); xchat->bind( chat_me, xport); connect(xchat, SIGNAL(readyRead()), this, SLOT(processPendingDatagrams())); //TCP部分 server = new TcpSend(this); connect(server,SIGNAL(sendFileName(QString)),this,SLOT(sentFileName(QString))); connect(ui->textEdit,SIGNAL(currentCharFormatChanged(QTextCharFormat)),this,SLOT(currentFormatChanged(const QTextCharFormat))); }
Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(this); ui->label->setText("<a href=\"http://www.yafeilinux.com\"> www.yafeilinux.com </a>"); this->resize(850,550); ui->textEdit->setFocusPolicy(Qt::StrongFocus); ui->textBrowser->setFocusPolicy(Qt::NoFocus); ui->textEdit->setFocus(); ui->textEdit->installEventFilter(this); udpSocket = new QUdpSocket(this); port = 45454; udpSocket->bind(port,QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); connect(udpSocket,SIGNAL(readyRead()),this,SLOT(processPendingDatagrams())); sendMessage(NewParticipant); server = new TcpServer(this); connect(server,SIGNAL(sendFileName(QString)),this,SLOT(sentFileName(QString))); connect(ui->textEdit,SIGNAL(currentCharFormatChanged(QTextCharFormat)),this,SLOT(currentFormatChanged(const QTextCharFormat))); }