宏定义:
Q_GLOBAL_STATIC(NotifyManager,theInstance)
函数定义:
class NotifyManager : public QObject { Q_OBJECT public: NotifyManager(QObject *parent = nullptr); ~NotifyManager(); static NotifyManager*getInstance(); //单例模式 }
源代码:
NotifyManager * NotifyManager::getInstance() { return theInstance(); }