#include "ExTcpClient.h" #include "ui_ExTcpClient.h" ExTcpClient::ExTcpClient(QWidget *parent) : QMainWindow(parent), ui(new Ui::ExTcpClient) { ui->setupUi(this); } ExTcpClient::~ExTcpClient() { delete ui; } QString ExTcpClient::getLocalIp() { QString hostName = QHostInfo::localHostName(); QHostInfo hostInfo = QHostInfo::fromName(hostName); ui->plainTextEdit->appendPlainText("本机名称:" + hostName); QString localIp; foreach (QHostAddress addr, hostInfo.addresses()) { if (QAbstractSocket::IPv4Protocol == addr.toString()) { localIp = addr.toString(); break; } } return localIp; } void ExTcpClient::on_actConnect_triggered() { } void ExTcpClient::on_actDisconnect_triggered() { } void ExTcpClient::on_actClear_triggered() { ui->plainTextEdit->clear(); } void ExTcpClient::on_actQuit_triggered() { close(); }