qt_demoe/other/ntpclient/ntpclient.h

50 lines
998 B
C
Raw Permalink Normal View History

2019-11-29 08:40:37 +00:00
#ifndef NTPCLIENT_H
#define NTPCLIENT_H
/**
2021-09-26 01:50:09 +00:00
* Ntp :feiyangqingyun(QQ:517216493) 2017-02-16
2021-09-13 08:12:35 +00:00
* 1. NtpIP
2021-11-14 05:06:47 +00:00
* 2. ntp1.aliyun.com
* 3.
* 4.
2019-11-29 08:40:37 +00:00
*/
#include <QObject>
#include <QDateTime>
class QUdpSocket;
#ifdef quc
2020-12-24 10:00:09 +00:00
class Q_DECL_EXPORT NtpClient : public QObject
2019-11-29 08:40:37 +00:00
#else
class NtpClient : public QObject
#endif
{
Q_OBJECT
public:
static NtpClient *Instance();
explicit NtpClient(QObject *parent = 0);
private:
static QScopedPointer<NtpClient> self;
QString ntpIP;
QUdpSocket *udpSocket;
private slots:
void readData();
void sendData();
2021-05-30 09:33:52 +00:00
void setTime_t(uint secsSince1Jan1970UTC);
2019-11-29 08:40:37 +00:00
2021-11-14 05:06:47 +00:00
public Q_SLOTS:
//设置Ntp服务器IP
2019-11-29 08:40:37 +00:00
void setNtpIP(const QString &ntpIP);
//获取日期时间
void getDateTime();
2021-11-14 05:06:47 +00:00
Q_SIGNALS:
//收到时间返回
void receiveTime(const QDateTime &dateTime);
2019-11-29 08:40:37 +00:00
};
#endif // NTPCLIENT_H