qt_demoe/ntpclient/frmntpclient.cpp

28 lines
683 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"
frmNtpClient::frmNtpClient(QWidget *parent) : QWidget(parent), ui(new Ui::frmNtpClient)
{
ui->setupUi(this);
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)
{
ui->txtTime->setText(dateTime.toString("yyyy-MM-dd HH:mm:ss"));
}