32 lines
733 B
C++
32 lines
733 B
C++
#include "connect.h"
|
|
#include "ui_connect.h"
|
|
#include <QRegExpValidator>
|
|
#include "data_config.h"
|
|
|
|
Connect::Connect(QWidget *parent) :
|
|
QWidget(parent),
|
|
ui(new Ui::Connect)
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
QString exp = "\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.)"
|
|
"{3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b";
|
|
QRegExp rege(exp);
|
|
QValidator *Validator = new QRegExpValidator(rege);
|
|
ui->lineEdit_IP->setValidator(Validator);
|
|
}
|
|
|
|
Connect::~Connect()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void Connect::on_pushButton_connect_clicked()
|
|
{
|
|
g_strServerIp = ui->lineEdit_IP->text();
|
|
m_tcpClient = MyTcpClient::instance();
|
|
// 连接服务器
|
|
m_tcpClient->connectToServer(g_strServerIp, 10000);
|
|
}
|
|
|