Note that there are some explanatory texts on larger screens.

plurals
  1. POBB 10 Cascades Internet Check
    primarykey
    data
    text
    <p>I need to check the Internet Connection If I get Socket Error. I am proceeding like this,</p> <pre><code>void Client::socketError(QAbstractSocket::SocketError socketError) { HttpPost("https://www.google.co.in/"); } void Client::HttpPost(QString URL ) { QNetworkRequest request = QNetworkRequest(); request.setUrl(QUrl(URL)); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager(this); bool result = connect(mNetworkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(HttpResponse(QNetworkReply *))); mNetworkAccessManager-&gt;get(request); qDebug() &lt;&lt; "::: Client.cpp Request made to Service :::"; } void Client::HttpResponse(QNetworkReply* reply) { if (reply-&gt;error() == QNetworkReply::NoError) { qDebug() &lt;&lt; "\n Internet Ok **********"; } else { qDebug() &lt;&lt; "\n No Internet **********" &lt;&lt; reply-&gt;errorString(); showDialog("No Inernet"); } } </code></pre> <p>and I am connecting to Signals and Slots like </p> <pre><code>connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError))); </code></pre> <p>But some times I am getting "No Internet Dialog " Even If wi-fi Is Available. Why ?</p> <hr> <p>Method 2:</p> <pre><code>// this method will return true If Net is available false other wise // but even this is return false some times even Wi fi signal is Available bool Client::isNetworkAvailable() { bool isFound = false; QNetworkConfigurationManager netMgr; QList&lt;QNetworkConfiguration&gt; mNetList = netMgr.allConfigurations(QNetworkConfiguration::Active); if (mNetList.count() &gt; 0) { if (netMgr.isOnline()) { isFound = true; } } qDebug() &lt;&lt; "\n ************** isNetworkAvailable:::" &lt;&lt; isFound; return isFound; } </code></pre> <p>Is there a problem in my code?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload