1 Star 0 Fork 47

acktian/SocketTool

forked from c./SocketTool 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
tcpsocketwidget.cpp 1.22 KB
一键复制 编辑 原始数据 按行查看 历史
#include "tcpsocketwidget.h"
#include "ui_tcpsocketwidget.h"
TcpSocketWidget::TcpSocketWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::TcpSocketWidget)
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
setAttribute(Qt::WA_ShowModal);
setWindowFlags(Qt::Tool);
ui->lineEditPeerAddress->setText("127.0.0.1");
QIntValidator* portValidator = new QIntValidator(1, 65535, this);
ui->lineEditPort->setValidator(portValidator);
ui->lineEditPort->setText("60000");
}
TcpSocketWidget::~TcpSocketWidget()
{
delete ui;
}
void TcpSocketWidget::on_pushButtonOk_clicked()
{
int port = ui->lineEditPort->text().toInt();
if (ui->lineEditPort->text().isEmpty() || port <= 0)
return;
QString hostAddress = ui->lineEditPeerAddress->text();
if (hostAddress.isEmpty())
return;
QHostAddress host(hostAddress);
if (host.isNull())
return;
QObject *p = parent();
if (p != nullptr)
{
QTcpSocket* tcpSocket = new QTcpSocket(p);
if (tcpSocket != nullptr)
{
emit tcpSocketCreated(tcpSocket, host, port);
close();
}
}
}
void TcpSocketWidget::on_pushButtonCancel_clicked()
{
close();
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/acktian/SocketTool.git
[email protected]:acktian/SocketTool.git
acktian
SocketTool
SocketTool
master

搜索帮助