Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8938703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:41:30+00:00 2026-06-15T10:41:30+00:00

I am having an issue while pinging to Destination / local IP using QProcess.

  • 0

I am having an issue while pinging to Destination / local IP using QProcess. QProcess returns “0” when ping is Successfull while Also when ping gives “Network is Unreachable” error (seen manually on terminal).

Actually I need to check the network connection in my application. To implement it, i used a very simple concept of ping using QProcess. I need to pop up a messagebox if there is any network error otherwise application starts normally without any popup message.

Here is my code for ping :

   bool App::pingPcuStatus(void)
   {
     const QString IP ="192.168.49.44";
     bool ret = false;
     int status;

     if ( IP == "0.0.0.0") {
        status = 1;
     }
    else {
            QProcess pingProcess;
            QString exec = "ping";
            QStringList params;
            params << "-c" << "1" << IP;
            status = pingProcess.execute(exec, params); //status = 0 , if Ping Successfull
            pingProcess.close();
     }

    ret = (status) ? false : true;
    return ret;
    }

But while debugging I found, it returns “true” even i am not conected to network. (I tried manual ping with same command on terminal, it gives “Network is Unreachable” error).

This leads to a big bug in my case.

What is the best way to capture this error using QProcess or any other way to resolve it ???

Any Idea or Suggestion are welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:41:32+00:00Added an answer on June 15, 2026 at 10:41 am

    Original answer from https://stackoverflow.com/a/2148360/793796:

    QProcess pingProcess;
    QString exec = "ping";
    QStringList params;
    params << "-c" << "1" << IP;
    pingProcess.start(exec,params,QIODevice::ReadOnly);
    pingProcess.waitForFinished(-1);
    
    QString p_stdout = pingProcess.readAllStandardOutput();
    QString p_stderr = pingProcess.readAllStandardError();
    

    Then you can parse stdout & stderr.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having an issue while accessing single database instance using multiple/distributed Hibernate SessionFactories
I'm having an issue while using group-adjacent. Below a simplified XML snippet : <Paras>
I'm having an issue with GridFS while using MongoS for node-mongodb-native. I opened an
I'm having a visual issue while using an NSFetchedResultsController with a UITableView . I've
having this weird issue while inserting to MongoDB using PHP. My insertion code is
I'm having the following issue while using Flot for a graph. The input for
I'm having an issue while developing a basic Rails application. I've implemented Twitter Bootstrap
I've developed an android app and it is having an issue while the user
Im having an issue when im trying to read in a text file while
I am having this issue, but while trying to fix it as per the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.