#include "dialog.h"
#include "ui_dialog.h"
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
connect(&tcpSocket, SIGNAL(connected()), this, SLOT(sendRequest()));
connect(&tcpSocket, SIGNAL(readyRead()), this, SLOT(readResponse()));
}
Dialog::~Dialog()
{
delete ui;
}
void Dialog::on_pushButton_clicked()
{
tcpSocket.connectToHost("127.0.0.1",7788);
}
void Dialog::sendRequest()
{
QTextStream out(&tcpSocket);
out<<ui->lineEdit_3->text();
}
void Dialog::readResponse()
{
QTextStream in(&tcpSocket);
ui->textBrowser->insertPlainText(in.readAll()+"\n");
tcpSocket.close();
}