Unsolved How to close QMessagebox with command automatically?
-
Hi All,
I'm trying to close the Messagebox that I utilize it to inform users that what my system is doing.
After the system has done the work then I will close the Messagebox.Here is the part of my code.
void MainWindow::on_pushButtonPT_Lantest_clicked() { if(!LanTabClick) { LanTabClick=true; initPTLan(); //QMessageBox::information(NULL,"information","Begin lan test",QMessageBox::Cancel); MsgBox->information(NULL,"information","Begin lan test",QMessageBox::Cancel); /*MsgBox.setText("Begin lan test"); MsgBox.setIcon(QMessageBox::Information); MsgBox.setStandardButtons(QMessageBox::Cancel); MsgBox.exec();*/ } } void MainWindow::Lanshow(QString speed) { qDebug()<<"forenex victor speed:"<<speed; QString check,eth1; eth0_destination="/sbin/route -n | /bin/grep 255 | /bin/grep eth0"; qDebug("In Lanshow"); if(!Lanpingperf->twoLAN) { qDebug("In Lanshow ,not twoLan"); if(speed.indexOf("failed")!=-1 || speed=="" || speed.right(11)=="unreachable") { qDebug("speed failed"); ui->lineEditPT_LANResult->setText("Failed"); ui->pushButtonPT_LAN_ResultLight->setStyleSheet("QPushButton{background-color:red;}"); test_result[12]=false; ui->textEditPT_LAN->setText("LAN is not working. Cannot ping 8.8.8.8!!!! "); LanTabClick=false; } else { qDebug("speed Pass"); ui->lineEditPT_LANResult->setText("Pass"); ui->pushButtonPT_LAN_ResultLight->setStyleSheet("QPushButton{background-color:green;}"); test_result[12]=true; ui->textEditPT_LAN->setText("LAN speed = "+speed); LanTabClick=false; } MsgBox->close(); } }
I will enable the Messagebox in function on_pushButtonPT_Lantest_clicked then wanna close it in function Lanshow.
However, the message box shows perfectly but cannot close it when running MsgBox->close().What did I miss?
Thanks in Advanced!
-
You're looking for something like a QProgressDialog but not for a QMessageBox which requires user interaction.