Singleton instance of QSplashScreen
- 
You can make wrapper class for working with QSplashScreen and use it as singleton. 
- 
Just create your own custom singleton-class which will have private QSplashScreen field and two public methods: one for setting this field (from place where you are creating splashscreen) and second for setting message. 
- 
Mmm, QApplication is commonly initialized in main() method. Maybe you mean QSplashScreen? If yes, than I think it will be ok for you to init it in main() too. 
- 
@class MySplash : public QSplashScreen 
 {
 Q_OBJECT
 public:
 explicit MySplash(QObject parent = 0);
 static MySplash instance();private: 
 MySplash* _inst;
 }@
 .cpp
 @
 MySplash MySplash::_inst = 0;
 MySplash* MySplash::instance()
 {
 if ( !_inst )
 _inst = new MySplash();
 return _inst;
 }@
- 
@class SplashScreen : public QSplashScreen{ public: static SplashScreen* getInstance(); void destroyInstance(); 
 void SetSplashScreen();
 void SetMessage(const std::wstring& message);
 QString *splashMessage;
 CString progressText;private: 
 QSplashScreen *hostSplash_;
 SplashScreen() {}~SplashScreen(){} static SplashScreen* m_pInstance; };@.h file 
- 
@SplashScreen* SplashScreen::m_pInstance = NULL; SplashScreen* SplashScreen::getInstance() { if(NULL == m_pInstance ) { m_pInstance = new SplashScreen(); } 
 return m_pInstance;
 }void SplashScreen::destroyInstance() { delete m_pInstance; 
 m_pInstance = NULL;
 }void SplashScreen::SetMessage(const std::wstring& message ) { progressText = message.c_str(); 
 char pC = (char)(LPCTSTR)progressText ;
 splashMessage->append(QString::fromAscii(pC));
 hostSplash_->showMessage(*splashMessage);} 
 void SplashScreen::SetSplashScreen() {
 hostSplash_ = new QSplashScreen(QPixmap(":Resource Files/splash.jpg"));
 }@
- 
Why do you use CString and std::wstring for setting/storing text? Why not QString? Also using CString and LPCTSTR type will break cross-platform compatibility. 
- 
2moderators of this section: please move this thread to more correspondent category (Desktop I think) 
