diff --git a/TcpClient.pro.user b/TcpClient.pro.user index fc40d01..15c56b6 100644 --- a/TcpClient.pro.user +++ b/TcpClient.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/login.cpp b/login.cpp index 3d41149..8f2d1f9 100644 --- a/login.cpp +++ b/login.cpp @@ -8,6 +8,7 @@ Login::Login(QWidget *parent) : /**********ui_init**********/ ui->setupUi(this); this->setWindowIcon(QIcon(":/icon.png")); + this->setTabOrder(ui->lineEdit_username,ui->lineEdit_password); this->setWindowFlags(Qt::FramelessWindowHint); //无边框 this->setAttribute(Qt::WA_TranslucentBackground); new_closebutton(ui->close_btn,":/close.png", QSize(30, 30)); diff --git a/mainwidget.cpp b/mainwidget.cpp index 2be44fe..23fc1fd 100644 --- a/mainwidget.cpp +++ b/mainwidget.cpp @@ -87,6 +87,7 @@ void MainWidget::on_save_btn_clicked() stream << str; //关闭文件 file.close(); + QMessageBox::information(this,"保存聊天记录","保存成功!"); } } else @@ -100,6 +101,7 @@ void MainWidget::on_save_btn_clicked() stream << str; //关闭文件 file.close(); + QMessageBox::information(this,"保存聊天记录","保存成功!"); } } } @@ -130,9 +132,19 @@ void MainWidget::on_send_btn_clicked() QString data_text = insert + text.mid(n,-1); QString text_self = QString("私发给%1:%2").arg(to_user).arg(text.mid(n)); qDebug() << text_self; - if(to_user == username) + int index = 0; + for (index = 0; index < ui->name_list->count(); index++) { - QMessageBox::critical(this,"错误","不能自己给自己发送消息!"); + if(username ==ui->name_list->item(index)->text()) + { + QMessageBox::critical(this,"错误","不能自己给自己发送消息!"); + return; + } + } + if(index >= ui->name_list->count()) + { + QMessageBox::critical(this,"错误","未找到指定用户!"); + return; } else {