mardi 28 avril 2015

Qt QProccess with ping utility usage

I need some help with QProcess class' method called "execute"

I wanna know is server alive using external utility "ping" in windows7. I make:

int exitCode = QProcess::execute(QString("ping -n %1 %2").arg(packetNumber).arg(hostAddr.toString()));
if (exitCode == 0){
    // it's alive
    qDebug() << "It's alive!";
}
else{
    // it's dead
    qDebug() << "It's dead!";
}

External prints into the console some info, that I don't want see. Ideally I want to run my function (part of its body is written upper) in the child thread. Other words, I just want to get "It's dead\alive !" in console from these code lines

Aucun commentaire:

Enregistrer un commentaire