单列模版 #ifndef _SINGTON_H_ #define _SINGTON_H_ #include <QMutex> #include <QSharedPointer> template<typename T> class Singleton { public: static T *instance() { if(m_instance.isNull()){ QMutexLocker lock(&m_mutex); if(m_instance.isNull()){ m_instance=QSharedPointer<T>(new T); } } return m_instance