<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to close QMessagebox with command automatically?]]></title><description><![CDATA[<p dir="auto">Hi All,<br />
I'm trying to close the Messagebox that I utilize it to inform users that what my system is doing.<br />
After the system has done the work then I will close the Messagebox.</p>
<p dir="auto">Here is the part of my code.</p>
<pre><code>void MainWindow::on_pushButtonPT_Lantest_clicked()
{
    if(!LanTabClick)
    {
        LanTabClick=true;
        initPTLan();
        //QMessageBox::information(NULL,"information","Begin lan test",QMessageBox::Cancel);
        MsgBox-&gt;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()&lt;&lt;"forenex victor speed:"&lt;&lt;speed;
    QString check,eth1;
    eth0_destination="/sbin/route -n | /bin/grep 255 | /bin/grep eth0";
    qDebug("In Lanshow");
    if(!Lanpingperf-&gt;twoLAN)
    {
        qDebug("In Lanshow ,not twoLan");
        if(speed.indexOf("failed")!=-1 || speed=="" || speed.right(11)=="unreachable")
        {
            qDebug("speed failed");
            ui-&gt;lineEditPT_LANResult-&gt;setText("Failed");
            ui-&gt;pushButtonPT_LAN_ResultLight-&gt;setStyleSheet("QPushButton{background-color:red;}");
            test_result[12]=false;
            ui-&gt;textEditPT_LAN-&gt;setText("LAN is not working. Cannot ping 8.8.8.8!!!! ");
            LanTabClick=false;
        }
        else
        {
            qDebug("speed Pass");
            ui-&gt;lineEditPT_LANResult-&gt;setText("Pass");
            ui-&gt;pushButtonPT_LAN_ResultLight-&gt;setStyleSheet("QPushButton{background-color:green;}");
            test_result[12]=true;
            ui-&gt;textEditPT_LAN-&gt;setText("LAN speed = "+speed);
            LanTabClick=false;
        }
        MsgBox-&gt;close();
  }
}
</code></pre>
<p dir="auto">I will enable the Messagebox in function on_pushButtonPT_Lantest_clicked then wanna close it in function Lanshow.<br />
However, the message box shows perfectly but cannot close it when running MsgBox-&gt;close().</p>
<p dir="auto">What did I miss?</p>
<p dir="auto">Thanks in Advanced!</p>
]]></description><link>https://forum.qt.io/topic/97814/how-to-close-qmessagebox-with-command-automatically</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Apr 2026 14:48:28 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/97814.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 19 Dec 2018 17:36:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to close QMessagebox with command automatically? on Wed, 19 Dec 2018 17:38:46 GMT]]></title><description><![CDATA[<p dir="auto">You're looking for something like a QProgressDialog but not for a QMessageBox which requires user interaction.</p>
]]></description><link>https://forum.qt.io/post/500378</link><guid isPermaLink="true">https://forum.qt.io/post/500378</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Wed, 19 Dec 2018 17:38:46 GMT</pubDate></item></channel></rss>