qt_demoe/other/ntpclient/frmntpclient.cpp

30 lines
753 B
C++
Raw Normal View History

2019-11-29 08:40:37 +00:00
#pragma execution_character_set("utf-8")
#include "frmntpclient.h"
#include "ui_frmntpclient.h"
#include "ntpclient.h"
2021-09-20 04:45:58 +00:00
#include "qdebug.h"
2019-11-29 08:40:37 +00:00
frmNtpClient::frmNtpClient(QWidget *parent) : QWidget(parent), ui(new Ui::frmNtpClient)
{
ui->setupUi(this);
2021-03-08 01:10:04 +00:00
ui->txtNtpIP->setText("ntp1.aliyun.com");
2019-11-29 08:40:37 +00:00
connect(NtpClient::Instance(), SIGNAL(receiveTime(QDateTime)), this, SLOT(receiveTime(QDateTime)));
}
frmNtpClient::~frmNtpClient()
{
delete ui;
}
void frmNtpClient::on_btnGetTime_clicked()
{
NtpClient::Instance()->setNtpIP(ui->txtNtpIP->text().trimmed());
NtpClient::Instance()->getDateTime();
}
void frmNtpClient::receiveTime(const QDateTime &dateTime)
{
2021-03-20 05:54:55 +00:00
ui->txtTime->setText(dateTime.toString("yyyy-MM-dd HH:mm:ss zzz"));
2019-11-29 08:40:37 +00:00
}