You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
998 B

#ifndef NTPCLIENT_H
#define NTPCLIENT_H
/**
* Ntp :feiyangqingyun(QQ:517216493) 2017-02-16
* 1. NtpIP
* 2. ntp1.aliyun.com
* 3.
* 4.
*/
#include <QObject>
#include <QDateTime>
class QUdpSocket;
#ifdef quc
class Q_DECL_EXPORT NtpClient : public QObject
#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();
void setTime_t(uint secsSince1Jan1970UTC);
public Q_SLOTS:
//设置Ntp服务器IP
void setNtpIP(const QString &ntpIP);
//获取日期时间
void getDateTime();
Q_SIGNALS:
//收到时间返回
void receiveTime(const QDateTime &dateTime);
};
#endif // NTPCLIENT_H