#ifndef SINGLETON_H #define SINGLETON_H #include <QObject> template < typename T > class Singleton { public: static T* getInstance(); private: static T* c_instance; }; template < typename T > T* Singleton<T>::c_instance = NULL; template < typename T > T* Singleton<T>::getInstance() { if(nullptr == c_instance) { c_instance = new T(); } return c_instance; } #endif // SINGLETON_H