Singleton instance of QSplashScreen
-
wrote on 29 Sept 2010, 12:29 last edited by
@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"));
}@ -
wrote on 29 Sept 2010, 12:33 last edited by
prakash02, and?
-
wrote on 29 Sept 2010, 12:35 last edited by
This is .cpp file.
I initialized the QApplication in main function, but my doubt does i can use the SplashScreen instance other than from main class.
Any help is appreciable.Thanks in advance.
-
wrote on 29 Sept 2010, 12:36 last edited by
prakash02, @SplashScreen* SplashScreen::m_pInstance = NULL;@ it's C style, it's better to use C++ style:
@SplashScreen* SplashScreen::m_pInstance = 0;@ -
wrote on 29 Sept 2010, 12:37 last edited by
And why do you use std::wstring instead QString?
-
wrote on 29 Sept 2010, 12:42 last edited by
I defined resource file of strings,now i want to use those messages to be display on QSplashScreen when the program execution calls that function which can be on different namespace or on different class.
-
wrote on 29 Sept 2010, 12:45 last edited by
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.
-
wrote on 29 Sept 2010, 12:48 last edited by
Denis Kormalev. :)
-
wrote on 29 Sept 2010, 12:48 last edited by
2moderators of this section: please move this thread to more correspondent category (Desktop I think)
-
wrote on 29 Sept 2010, 12:50 last edited by
prakash02, how do you defiine resource file of strings?
-
wrote on 29 Sept 2010, 12:52 last edited by
Yes i can use QString, but previously those are used to display on the native windows dialog.Now I want to change those to QT to improve the look and feel.
-
wrote on 4 Oct 2010, 06:10 last edited by
try to use QObject::tr("") for strings instead string table in resource file.
18/20