Hello there. I'm trying to make a ping application. The application start but nothing is shown.
Here is my code.
#include "ping.h"
#include "ui_ping.h"
//#include <iostream>
//#include <stdio.h>
//#include <stdlib.h>
#include <QtGui>
#include <QApplication>
#include <QMessageBox>
#include <QTextEdit>
#include <QtNetwork/QTcpSocket>
#include <QPlainTextEdit>
#include <QtNetwork>
//using namespace std;
ui(new Ui::ping)
{
ui->setupUi(this);
}
ping::~ping()
{
delete ui;
}
void ping::on_pushButton_clicked()
{
QString m_sHostName
= ui
->lineEdit
->text
();
// Create QProcess object
proc->waitForFinished(-1);
// Show output
ui->plainTextEdit->connect(proc, SIGNAL(readyReadStandardOutput()), this, SLOT(show()));
ui->plainTextEdit->connect(proc, SIGNAL(readyReadStandardError()), this, SLOT(show()));
}
// Show right message
void ping::rightMessage()
{
QByteArray strdata
= proc
->readAllStandardOutput
();
strdata = strdata.simplified();
strdata = strdata.trimmed();
//ui->TextEditResult->setTextColor(Qt::black);
ui->plainTextEdit->appendPlainText(strdata);
// ui->plainTextEdit->appendPlainText("<br>");
}
// Show wrong message
void ping::wrongMessage()
{
QByteArray strdata
= proc
->readAllStandardError
();
//ui->TextEditResult->setTextColor(Qt::red);
ui->plainTextEdit->appendPlainText(strdata);
}
#include "ping.h"
#include "ui_ping.h"
//#include <iostream>
//#include <stdio.h>
//#include <stdlib.h>
#include <QtGui>
#include <QApplication>
#include <QMessageBox>
#include <QTextEdit>
#include <QtNetwork/QTcpSocket>
#include <QPlainTextEdit>
#include <QtNetwork>
//using namespace std;
ping::ping(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::ping)
{
ui->setupUi(this);
}
ping::~ping()
{
delete ui;
}
void ping::on_pushButton_clicked()
{
QString m_sHostName = ui->lineEdit->text();
// Create QProcess object
QProcess *proc;
proc = new QProcess();
proc->start("ping", QStringList() << QString(m_sHostName), QIODevice::ReadOnly);
proc->waitForFinished(-1);
// Show output
ui->plainTextEdit->connect(proc, SIGNAL(readyReadStandardOutput()), this, SLOT(show()));
ui->plainTextEdit->connect(proc, SIGNAL(readyReadStandardError()), this, SLOT(show()));
}
// Show right message
void ping::rightMessage()
{
QProcess *proc;
proc = new QProcess();
QByteArray strdata = proc->readAllStandardOutput();
strdata = strdata.simplified();
strdata = strdata.trimmed();
//ui->TextEditResult->setTextColor(Qt::black);
ui->plainTextEdit->appendPlainText(strdata);
// ui->plainTextEdit->appendPlainText("<br>");
}
// Show wrong message
void ping::wrongMessage()
{
QProcess *proc;
proc = new QProcess();
QByteArray strdata = proc->readAllStandardError();
//ui->TextEditResult->setTextColor(Qt::red);
ui->plainTextEdit->appendPlainText(strdata);
}
To copy to clipboard, switch view to plain text mode
Bookmarks