#include "italkingwidget.h" #include "../JusCall/JusCallPch.h" #include "ui_talking.h" #include "ivideoitemteach.h" #include "../mainapp.h" #include #include #include #include #include #include "qwebpage.h" #include "iwebrequest.h" #include "JusDoodle/DoodleManager.h" #include "downloadfile.h" #include #include "GlobalSetting.h" #include "gotyecpp/gotyemsg.h" #include "gotye/GotyeMessage.h" #include "gotye/GotyeAPI.h" USING_NS_GOTYEAPI; const QSize SIZEHVIDEO = QSize(640 + VIDEOSHADOW_WIDTH, 480 + VIDEOSHADOW_HEIGHT); const QSize SIZEVVIDEO = QSize(480 + VIDEOSHADOW_WIDTH, 640 + VIDEOSHADOW_HEIGHT); ITalkingWidget::ITalkingWidget(QWidget *parent) : QWidget(parent),ui(new Ui::TalkingWidget()) { ui->setupUi(this); // videoItemTeacher = new IVideoItemTeach(ui->widgetCenter);//教师视频窗口 videoItemTeacher = new QWidget(ui->label_left);//教师视频窗口 videoItemTeacher->setStyleSheet("border-image: url(:/Images/VideoCall/teacher_default.png);"); videoItemTeacher->resize(290, 290); videoItemTeacher->move(10, 10); videoItemTeacher->show(); volSlider = new ISlider(ui->widgetCenter);//这个初始值,是让这个控件竖向布局 volSlider->setOrientation(Qt::Vertical); // volSlider->setGeometry(603,510,20,106); volSlider->setRange(0,20); volSlider->setPageStep(1); volSlider->hide(); QFile qss(":qss/QSlider.qss"); if(qss.open(QFile::ReadOnly)) { QString text= qss.readAll(); volSlider->setStyleSheet(text); qss.close(); } setMouseTracking(true); setFocus(Qt::MouseFocusReason); connect((MainApp *)qApp, SIGNAL(videoEvent(int, const Notification&)), SLOT(onVideoEvent(int, const Notification&))); // initShowUI(); MyTimer.setSingleShot(true); trayHideTimer.setSingleShot(true); m_hanging_up_timer = new QTimer(); m_hanging_up_timer->setSingleShot(true); //最小化 connect(ui->pushButtonMin, SIGNAL(clicked()), this, SIGNAL(hideMain())); //悬浮框各控件控制 connect(ui->pushButtonMic, SIGNAL(mouseIn()), this, SLOT(MicLabelShow())); connect(&MyTimer, SIGNAL(timeout()), volSlider, SLOT(hide())); connect(m_hanging_up_timer, SIGNAL(timeout()), this, SLOT(on_pushButtonCloseVideo_clicked())); connect(ui->pushButtonCameraChange, SIGNAL(mouseIn()), this, SLOT(CameraLabelShow())); connect(volSlider, SIGNAL(mouseOut()), this, SLOT(volSliderHide())); connect(volSlider, SIGNAL(mouseIn()), &MyTimer, SLOT(stop())); connect(ui->pushButtonVol, SIGNAL(mouseIn()), this, SLOT(volSliderShow())); connect(ui->pushButtonVol, SIGNAL(mouseOut()), this, SLOT(volSliderHide())); connect(volSlider, SIGNAL(valueChanged(int)), this, SLOT(SetSpkVol(int))); // connect(ui->labelVideoShow, SIGNAL(mouseIn()), this, SLOT(widgettrayShow())); // connect(ui->labelVideoShow, SIGNAL(mouseOut()), this, SLOT(widgettrayHide())); // connect(&trayHideTimer,SIGNAL(timeout()),ui->widgettray, SLOT(hide())); connect(ui->widgettray, SIGNAL(mouseIn()), this, SLOT(widgettrayShow())); connect(ui->widgettray, SIGNAL(mouseOut()), this, SLOT(widgettrayHide())); connect(IWebRequest::Instance(), SIGNAL(response(int,int,QString,QString)), this, SLOT(doResponse(int,int,QString,QString))); ui->splitter->setStretchFactor(0,70); ui->splitter->setStretchFactor(1,30); ui->textEdit->installEventFilter(this); ui->pushButtonMessage->hide(); QFile source(":Images/style/style.html"); source.open(QIODevice::ReadOnly); ui->webView->setHtml(QString::fromUtf8(source.readAll().constData())); source.close(); m_timer = new QTimer(); connect( m_timer,SIGNAL(timeout()),this,SLOT(displayTime())); m_courseTimer = new QTimer(); m_courseTimer->setSingleShot(true); connect(m_courseTimer,SIGNAL(timeout()),this,SLOT(upCourseUi())); hint_label = new QLabel(this); hint_label->setAlignment(Qt::AlignCenter); hint_label->setStyleSheet("border-image: url(:/Images/VideoCall/transparent50.png);background-color:rgba(120,120,120,255);color:rgb(255,0,0);"); hint_label->hide(); ui_msgMemo = new msgMemo(); receiverUid = 0; pptNmu = 0; } void ITalkingWidget::MicLabelShow() { if (MyTimer.isActive()) { MyTimer.stop(); volSlider->hide(); } if(isClictMic) ui->pushButtonMic->setToolTip("Click to Mute"); else ui->pushButtonMic->setToolTip("Click to Unmute"); qDebug("CMQ MicLabelShow...\n"); } void ITalkingWidget::CameraLabelShow() { if (MyTimer.isActive()) { MyTimer.stop(); volSlider->hide(); } if(isClictCamera) ui->pushButtonCameraChange->setToolTip("Unable Webcam"); else ui->pushButtonCameraChange->setToolTip("Enable Webcam"); qDebug("CMQ CameraLabelShow...\n"); } void ITalkingWidget::volSliderShow() { int num_x = ui->labelVideoShowBK->x()+ui->pushButtonVol->x()+ui->pushButtonVol->width()/4; if (MyTimer.isActive()) MyTimer.stop(); if(isClictVol) ui->pushButtonVol->setToolTip("Click to Mute"); else ui->pushButtonVol->setToolTip("Click to Unmute"); volSlider->setValue(Mtc_CallGetSpkVol(RCallManager::Instance()->m_pRSession->sessId())); volSlider->setGeometry(num_x,510,20,106); volSlider->show(); qDebug("CMQ volSliderShow..%d..\n",Mtc_CallGetSpkVol(RCallManager::Instance()->m_pRSession->sessId())); } void ITalkingWidget::displayTime() { QString strtime = QString(""); callTimeSec++; QDateTime dt = QDateTime::fromTime_t(callTimeSec); if(callTimeSec >= 3600) strtime = dt.toString("hh:mm:ss");//日期格式自定义 else strtime = dt.toString("mm:ss");//日期格式自定义 ui->label_time->setText(strtime); } void ITalkingWidget::SetSpkVol(int value) { Mtc_CallSetSpkVol(RCallManager::Instance()->m_pRSession->sessId(),value); qDebug("CMQ SetSpkVol..%d..\n",volSlider->value()); } void ITalkingWidget::widgettrayShow() { //volSlider->hide(); if (trayHideTimer.isActive()) trayHideTimer.stop(); ui->widgettray->show(); } void ITalkingWidget::widgettrayHide() { //volSlider->hide(); if (trayHideTimer.isActive()) trayHideTimer.stop(); trayHideTimer.start(3*1000); } void ITalkingWidget::volSliderHide() { //volSlider->hide(); if (MyTimer.isActive()) MyTimer.stop(); MyTimer.start(2*1000); } int ITalkingWidget::getSendUid() { QString s_uid = QString::fromLatin1(Mtc_CallGetPeerName(RCallManager::Instance()->m_pRSession->sessId())); receiverUid = s_uid.remove(0,2).toInt(); if(receiverUid > 0) { GotyeUser userInfo; QString user(QString("%1").arg(receiverUid)); GotyeChatTarget getSender(user.toLatin1().data()); userInfo = apiist->getUserDetail(getSender); if(strlen(userInfo.icon.path.data()) > 1) { apiist->downloadMedia(userInfo.icon); otherhead = QString::fromStdString(userInfo.icon.path); otherhead.replace("\\","/"); } else userInfo = apiist->getUserDetail(getSender,true); apiist->activeSession(getSender); // < 激活与target的会话 qDebug("CMQ getSendUid otherhead = %s.....\n",userInfo.icon.path.data()); } return receiverUid; } void ITalkingWidget::initShowUI() { videoFlag = true; isClictMic = true; isClictVol = true; isClictCamera = true; ui->pushButtonMic->setStyleSheet("QPushButton{background:transparent;border-image: url(:Images/VideoCall/icon_mic_nor.png);}" "QPushButton:hover{border-image: url(:Images/VideoCall/icon_mic_hov.png);}" "QPushButton:pressed{border-image: url(:Images/VideoCall/icon_mic_pre.png);}"); ui->pushButtonCameraChange->setStyleSheet("QPushButton{background:transparent;border-image: url(:Images/VideoCall/img_video_off_nor.png);}" "QPushButton:hover{border-image: url(:Images/VideoCall/img_video_off_hov.png);}" "QPushButton:pressed{border-image: url(:Images/VideoCall/img_video_off_pre.png);}"); ui->pushButtonVol->setStyleSheet("QPushButton{background:transparent;border-image: url(:Images/VideoCall/icon_vol_nor.png);}" "QPushButton:hover{border-image: url(:Images/VideoCall/icon_vol_hov.png);}" "QPushButton:pressed{border-image: url(:Images/VideoCall/icon_vol_pre.png);}"); ui->textEdit->setFocus(); if(_GlobalSetting.userHeadImg.file_name.length() > 2) Myhead = QCoreApplication::applicationDirPath()+"/img/"+_GlobalSetting.userHeadImg.file_name +_GlobalSetting.userHeadImg.ext; hint_label->hide();; callTimeSec = 0; m_timer->start(1000); GotyeMsg::Instance()->setShowUserName(ui->label_name); GotyeMsg::Instance()->setIsUpdata(true); if(receiverUid < 1) getSendUid(); showCourseUi(); GotyeMsg::Instance()->uidGetChatLog(receiverUid); } //刷新课程PPT void ITalkingWidget::upCourseUi() { QStringList imagePaths = QStringList(); // pptNmu = pptarray.size(); for(int i = 0;i < pptarray.size();i++) { QString couresFile = QCoreApplication::applicationDirPath()+"/couresImg/"+pptarray.at(i).toObject().\ find("pic").value().toObject().find("file_name").value().toString(); imagePaths << couresFile; } pSess->setBackgroundImages(imagePaths); } void ITalkingWidget::showCourseUi() { if(pptNmu > 1) { GotyeMsg::Instance()->setShowMsgWebviwe(ui_msgMemo->getMsgView()); QVBoxLayout *vLayout = (QVBoxLayout *)ui->label_left->layout(); if(vLayout) delete vLayout; vLayout = new QVBoxLayout(); vLayout->addWidget(videoItemTeacher,19); vLayout->addWidget(ui->labelVideoShowBK,21); vLayout->setSpacing(0); vLayout->setContentsMargins(0,2,0,2); ui->label_left->setLayout(vLayout); ui->widget_meg->hide(); pSess = JusDoodle::DoodleManager::Instance()->findSess(RCallManager::Instance()->m_pRSession->sessId()); if(!pSess) return; if (!pSess->_doodleWindow) pSess->initWindow(pptarray.size()); pSess->_doodleWindow->show(); ui->horizontalLayoutCenter->addWidget(pSess->_doodleWindow); m_courseTimer->start(8*1000); upCourseUi(); connect(pSess->_doodleWindow->ui->btnMessage,SIGNAL(clicked()),ui_msgMemo,SLOT(show())); connect(pSess->_doodleWindow->ui->btnNote,SIGNAL(clicked()),ui_msgMemo,SLOT(show())); } else { GotyeMsg::Instance()->setShowMsgWebviwe(ui->webView); QVBoxLayout *vLayout = (QVBoxLayout *)ui->label_left->layout(); if(vLayout) delete vLayout; videoItemTeacher->resize(290, 320); videoItemTeacher->move(0, 2); // ui->horizontalLayoutCenter->setSpacing(5); ui->horizontalLayoutCenter->addWidget(ui->label_left); ui->horizontalLayoutCenter->addWidget(ui->labelVideoShowBK); ui->horizontalLayoutCenter->addWidget(ui->widget_meg); ui->widget_meg->show(); } } void ITalkingWidget::doResponse(int cmd,int,QString,QString result) { switch(cmd) { //通话课程 case REQ_USER_COURSE_CALL_GET: { QJsonParseError jsonErr; QJsonDocument myjsonDoc1 = QJsonDocument::fromJson(result.toLatin1(),&jsonErr); pptarray = myjsonDoc1.object().find("result").value().toObject().find("ppt").value().toArray(); QJsonObject courseInfo = myjsonDoc1.object().find("result").value().toObject().find("courseInfo").value().toObject(); // qDebug()<<"course: "<addDownloadFile(url,couresFile,fileId); } } downfile->startDownloadFile(); break; } } } void ITalkingWidget::onVideoEvent(int eventType, const Notification &_info) { Notification info = (Notification &)_info; switch (eventType) { case ZmfVideoRenderDidReceive: ;//if (info.getIntValue(ZmfWindow) == (int)m_pVideoRemote->winId()) { // showSessVideoSize(info.getIntValue(ZmfWidth), info.getIntValue(ZmfHeight)); } break; } qDebug("CMQ onVideoEvent..eventType = %d..\n",eventType); } //void ITalkingWidget::on_pushButtonMin_clicked() //{ // this->showMinimized(); //} void ITalkingWidget::slotClickedBtnAnswer() { Mtc_CallAnswer(RCallManager::Instance()->m_pRSession->sessId(), 0, ZTRUE, ZTRUE); } void ITalkingWidget::slotClickedBtnDecline() { Mtc_CallTerm(RCallManager::Instance()->m_pRSession->sessId(), EN_MTC_CALL_TERM_STATUS_DECLINE, ZNULL); //showSessTermed(); } void ITalkingWidget::slotClickedBtnEnd() { Mtc_CallTerm(RCallManager::Instance()->m_pRSession->sessId(), EN_MTC_CALL_TERM_STATUS_NORMAL, ZNULL); //showSessTermed(); } void ITalkingWidget::showSessTermed() { stopLocalVideo(); stopRemoteVideo(); } void ITalkingWidget::stopLocalVideo() { Zmf_VideoRenderRemoveAll((void *)videoItemTeacher->winId()); Zmf_VideoRenderStop((void *)videoItemTeacher->winId()); Zmf_VideoCaptureStopAll(); } void ITalkingWidget::startLocalVideo() { qDebug("%s %d %d", __FUNCTION__, m_nRemoteWidth, m_nRemoteHeight); ZUINT dwWidth, dwHeight, dwFramerate; QString cameraId = RCallManager::Instance()->getCamera(); // adjust size according to peer video resolution Mtc_CallGetVideoRemoteSize(RCallManager::Instance()->m_pRSession->sessId(), &dwWidth, &dwHeight); if (dwHeight == 720) { //slotShowFullSreen(); m_nRemoteWidth = dwWidth; m_nRemoteHeight = dwHeight; videoItemTeacher->resize(dwWidth, dwHeight); } // start capture Mtc_MdmGetCaptureParms(&dwWidth, &dwHeight, &dwFramerate); dwWidth = videoItemTeacher->width(); dwHeight = videoItemTeacher->height(); dwFramerate = 10; videoItemTeacher->resize(dwWidth, dwHeight); if (Zmf_VideoCaptureStart(cameraId.toUtf8().data(), dwWidth, dwHeight, dwFramerate) != 0) { qDebug("Failed to start capture."); return; } // start render if (Zmf_VideoRenderStart((void *)videoItemTeacher->winId(), ZmfRenderView) != 0) { qDebug("Failed to start render for capture."); Zmf_VideoCaptureStopAll(); return; } // add render if (Zmf_VideoRenderAdd((void *)videoItemTeacher->winId(), cameraId.toUtf8().data(), 0, ZmfRenderFullScreen) != 0) { qDebug("Failed to add render for capture."); Zmf_VideoRenderStop((void *)videoItemTeacher->winId()); Zmf_VideoCaptureStopAll(); return; } //resizeVideoWidgets(); raise(); } void ITalkingWidget::startRemoteVideo() { qDebug(__FUNCTION__); m_dwSessId = RCallManager::Instance()->m_pRSession->sessId(); // start render if (Zmf_VideoRenderStart((void *)ui->labelVideoShow->winId(), ZmfRenderView) != 0) { qDebug("Failed to start render for peer."); return; } // add render ZCONST ZCHAR *pcCallName = Mtc_CallGetName(m_dwSessId); if (Zmf_VideoRenderAdd((void *)ui->labelVideoShow->winId(), pcCallName, 0, ZmfRenderFullScreen) != 0) { qDebug("Failed to add render for peer."); Zmf_VideoRenderStop((void *)ui->labelVideoShow->winId()); return; } // attach camera Mtc_CallCameraAttach(m_dwSessId, RCallManager::Instance()->getCamera().toUtf8().data()); qDebug("CMQ startRemoteVideo OK..."); } void ITalkingWidget::stopRemoteVideo() { Zmf_VideoRenderRemoveAll((void *)ui->labelVideoShow->winId()); Zmf_VideoRenderStop((void *)ui->labelVideoShow->winId()); } void ITalkingWidget::on_pushButtonClose_clicked() { QMessageBox::StandardButton rb = QMessageBox::question(NULL, "Close", "Is on the phone, sure you want to shut down?", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); if(rb == QMessageBox::Yes) { on_pushButtonCloseVideo_clicked(); } } void ITalkingWidget::otherVideoReceive(bool flag) { if(!flag) { QFont font; font.setPointSize(15); hint_label->setGeometry(290,300,420,50); hint_label->setFont(font); stopRemoteVideo(); hint_label->setText(QString("The contact has turned off the webcam.")); hint_label->show(); // videoFlag = false; } else { startRemoteVideo(); // videoFlag = true; hint_label->setText(QString("The contact has turned on the webcam.")); QTimer::singleShot(3*1000,hint_label,SLOT(hide())); // hint_label->hide(); } } /* 对方挂断了通话 */ void ITalkingWidget::closeTheCurrentCall(QString) { QFont font; font.setPointSize(18); hint_label->setGeometry(260,300,500,50); hint_label->setFont(font); stopRemoteVideo(); hint_label->setText(QString("The other has stopped the video chat.")); hint_label->show(); if(!m_hanging_up_timer->isActive()) m_hanging_up_timer->start(3*1000); } /* 未接提醒 */ void ITalkingWidget::repulseCurrentCall() { if (!RCallManager::Instance()->m_pRSession) return; if(receiverUid < 1) { getSendUid(); GotyeMsg::Instance()->sendMessage(QString("%1").arg(receiverUid), "Sorry! I am not available now. Please try again later.",GotyeMessageTypeText); // qDebug("CMQ on_pushButtonCloseVideo_clicked %d...111\n",receiverUid); } on_pushButtonCloseVideo_clicked(); } /* 主动挂断了通话 */ void ITalkingWidget::on_pushButtonCloseVideo_clicked() { if (!RCallManager::Instance()->m_pRSession) return; QString user(QString("%1").arg(receiverUid)); GotyeChatTarget getSender(user.toLatin1().data()); apiist->deactiveSession(getSender); // < 隐藏与target的会话 slotClickedBtnEnd(); receiverUid = 0; callTimeSec = 0; m_timer->stop(); stopCalling(); if(pSess) delete pSess; pptNmu = 0; } void ITalkingWidget::on_pushButtonMic_clicked() { if(isClictMic) { Mtc_CallSetMicMute(RCallManager::Instance()->m_pRSession->sessId(),isClictMic); isClictMic = false; ui->pushButtonMic->setStyleSheet("QPushButton{background:transparent;border-image: url(:Images/VideoCall/icon_closemic_nor.png);}" "QPushButton:hover{border-image: url(:Images/VideoCall/icon_closemic_hov.png);}" "QPushButton:pressed{border-image: url(:Images/VideoCall/icon_closemic_pre.png);}"); } else { Mtc_CallSetMicMute(RCallManager::Instance()->m_pRSession->sessId(),isClictMic); isClictMic = true; ui->pushButtonMic->setStyleSheet("QPushButton{background:transparent;border-image: url(:Images/VideoCall/icon_mic_nor.png);}" "QPushButton:hover{border-image: url(:Images/VideoCall/icon_mic_hov.png);}" "QPushButton:pressed{border-image: url(:Images/VideoCall/icon_mic_pre.png);}"); } qDebug("CMQ on_pushButtonMic_clicked...\n"); } void ITalkingWidget::on_pushButtonCameraChange_clicked() { if(isClictCamera) { isClictCamera = false; stopLocalVideo(); Mtc_CallVideoSetSend(RCallManager::Instance()->m_pRSession->sessId(),EN_MTC_CALL_TRANSMISSION_CAMOFF); ui->pushButtonCameraChange->setStyleSheet("QPushButton{background:transparent;border-image: url(:Images/VideoCall/img_video_on_nor.png);}" "QPushButton:hover{border-image: url(:Images/VideoCall/img_video_on_hov.png);}" "QPushButton:pressed{border-image: url(:Images/VideoCall/img_video_on_pre.png);}"); } else { isClictCamera = true; Mtc_CallVideoSetSend(RCallManager::Instance()->m_pRSession->sessId(),EN_MTC_CALL_TRANSMISSION_NORMAL); startLocalVideo(); showCourseUi(); ui->pushButtonCameraChange->setStyleSheet("QPushButton{background:transparent;border-image: url(:Images/VideoCall/img_video_off_nor.png);}" "QPushButton:hover{border-image: url(:Images/VideoCall/img_video_off_hov.png);}" "QPushButton:pressed{border-image: url(:Images/VideoCall/img_video_off_pre.png);}"); } qDebug("CMQ on_pushButtonCameraChange_clicked...\n"); } void ITalkingWidget::on_pushButtonVol_clicked() { if(isClictVol) { Mtc_CallSetSpkMute(RCallManager::Instance()->m_pRSession->sessId(),isClictVol); isClictVol = false; ui->pushButtonVol->setStyleSheet("QPushButton{background:transparent;border-image: url(:Images/VideoCall/icon_closevol_nor.png);}" "QPushButton:hover{border-image: url(:Images/VideoCall/icon_closevol_hov.png);}" "QPushButton:pressed{border-image: url(:Images/VideoCall/icon_closevol_pre.png);}"); // this->resize(QSize(1200,700)); } else { // this->resize(QSize(1000,700)); Mtc_CallSetSpkMute(RCallManager::Instance()->m_pRSession->sessId(),isClictVol); isClictVol = true; ui->pushButtonVol->setStyleSheet("QPushButton{background:transparent;border-image: url(:Images/VideoCall/icon_vol_nor.png);}" "QPushButton:hover{border-image: url(:Images/VideoCall/icon_vol_hov.png);}" "QPushButton:pressed{border-image: url(:Images/VideoCall/icon_vol_pre.png);}"); } qDebug("CMQ on_pushButtonVol_clicked...\n"); } void ITalkingWidget::on_pushButton_clicked() { if( ui->textEdit->toPlainText() == NULL ) { QMessageBox::warning( this , "warning","Message to be sent cannot be empty!" ); return; } /**自己发送的消息*/ if(receiverUid < 1) getSendUid(); // SendMsgShow( ui->textEdit->toPlainText(),Myhead); GotyeMsg::Instance()->sendMessage(QString("%1").arg(receiverUid), ui->textEdit->toPlainText(),GotyeMessageTypeText); ui->textEdit->clear(); ui->textEdit->activateWindow(); ui->textEdit->setFocus(); } void ITalkingWidget::on_pushButton_picture_clicked() { if(receiverUid < 1) getSendUid(); QFileDialog::Options options; //if (!native->isChecked()) options |= QFileDialog::DontUseNativeDialog; QString selectedFilter,openFilesPath; QStringList files = QFileDialog::getOpenFileNames( this, tr("QFileDialog::getOpenFileNames()"), openFilesPath, tr("Images (*.png *.bmp *.jpg)"), &selectedFilter, options); if (files.count()) { for(int i = 0;i < files.count();i++) { GotyeMsg::Instance()->sendMessage(QString("%1").arg(receiverUid), files[i],GotyeMessageTypeImage); // SendImageShow( files[i],Myhead); } } } bool ITalkingWidget::eventFilter(QObject *obj, QEvent *e) { // Q_ASSERT(obj == inputTextEdit); if (e->type() == QEvent::KeyPress) { QKeyEvent *event = static_cast(e); if ((event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) && (event->modifiers() & Qt::ControlModifier)) { ui->textEdit->append("");//换行 // on_pushButton_clicked(); //发送消息的槽 return true; } else if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) { on_pushButton_clicked(); //发送消息的槽 return true; } } return false; } void ITalkingWidget::on_pushButtonMessage_clicked() { static bool clickeMsg = false; // if(clickeMsg) // { // ui->widget->hide(); // clickeMsg = false; // } // else // { // ui->widget->show(); // clickeMsg = true; // } }