#include "clientmainwindow.h"
|
#include "ui_clientmainwindow.h"
|
#include <QDebug>
|
#pragma execution_character_set("utf-8")
|
|
ClientMainWindow::ClientMainWindow(QWidget *parent) :
|
QMainWindow(parent),
|
ui(new Ui::ClientMainWindow)
|
{
|
ui->setupUi(this);
|
|
m_client = new QTcpSocket(this);
|
m_client->connectToHost("127.0.0.1",16888);
|
if(m_client->waitForConnected()){
|
qDebug()<<"conn success";
|
//关联收包槽
|
connect(m_client,SIGNAL(readyRead()),this,SLOT(myRead()));
|
//调用界面初始化
|
initUi();
|
}else{
|
qDebug()<<"conn fail:"<<m_client->errorString();
|
}
|
|
|
}
|
|
ClientMainWindow::~ClientMainWindow()
|
{
|
delete ui;
|
}
|
|
void ClientMainWindow::initUi()
|
{
|
//m_logSer = new LogQuery(this);
|
m_logSer = new LogQuery(m_client,this);
|
ui->tabWidget->addTab(m_logSer,"日志查询");
|
connect(this,SIGNAL(queryResSignal(LogQueryRes*)),m_logSer,SLOT(queryResSlot(LogQueryRes*)));
|
}
|
|
void ClientMainWindow::myRead()
|
{
|
QByteArray buffer = m_client->readAll();
|
qDebug()<< "buffer.size():"<<buffer.size();
|
qDebug()<< "buffer:"<<buffer;
|
int type = ((Head*)buffer.data())->type;
|
qDebug()<<"type:"<<type;
|
if(type == LOGSEARCH_RES){
|
LogQueryRes *res = (LogQueryRes*)buffer.data();
|
qDebug()<< "status:"<<res->status;
|
emit queryResSignal(res);//发信号给日志查询界面
|
}
|
}
|