forked from HEU-F8-PRACTICE/HealthProj
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTCPSettingsWidget.cpp
More file actions
53 lines (45 loc) · 1.52 KB
/
TCPSettingsWidget.cpp
File metadata and controls
53 lines (45 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "TCPSettingsWidget.h"
TCPSettingsWidget::TCPSettingsWidget(QWidget *parent) : QWidget(parent)
{
ipLayout->addWidget(ipLabel);
ipLayout->addWidget(ipEdit);
portLayout->addWidget(portLabel);
portLayout->addWidget(portEdit);
buttonLayout->addWidget(testBtn);
buttonLayout->addWidget(applyBtn);
all->addLayout(ipLayout);
all->addLayout(portLayout);
all->addLayout(buttonLayout);
this->setLayout(all);
ipLabel->setText("IP:");
portLabel->setText("PORT:");
testBtn->setText("测试");
applyBtn->setText("应用");
connect(applyBtn, &QPushButton::clicked, this, &TCPSettingsWidget::setTCPIP);
connect(testBtn, &QPushButton::clicked, this, &TCPSettingsWidget::testTCPIP);
connect(this, &TCPSettingsWidget::testSig, socketForTest, &TCPSocket::testTCPIP);
connect(socketForTest, &TCPSocket::testSuccess, this, &TCPSettingsWidget::successTest);
connect(socketForTest, &TCPSocket::testFailed, this, &TCPSettingsWidget::failTest);
socketForTest->moveToThread(&thread);
thread.start();
}
void TCPSettingsWidget::setTCPIP()
{
emit tcpipChanged(ipEdit->text(), portEdit->text().toUInt());
}
void TCPSettingsWidget::testTCPIP()
{
emit testSig(ipEdit->text(), portEdit->text().toUInt());
}
void TCPSettingsWidget::successTest()
{
QMessageBox::information(NULL, "Success", "成功");
}
void TCPSettingsWidget::failTest()
{
QMessageBox::information(NULL, "Failed", "失败");
}
void TCPSettingsWidget::setWindowSize(int w, int h)
{
this->resize(w, h);
}