Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Behind the Scenes
  3. Wiki Discussion
  4. Singleton instance of QSplashScreen
QtWS25 Last Chance

Singleton instance of QSplashScreen

Scheduled Pinned Locked Moved Wiki Discussion
20 Posts 3 Posters 9.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    prakash02
    wrote on last edited by
    #9

    @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"));
    }@

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alexander
      wrote on last edited by
      #10

      prakash02, and?

      1 Reply Last reply
      0
      • P Offline
        P Offline
        prakash02
        wrote on last edited by
        #11

        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.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          alexander
          wrote on last edited by
          #12

          prakash02, @SplashScreen* SplashScreen::m_pInstance = NULL;@ it's C style, it's better to use C++ style:
          @SplashScreen* SplashScreen::m_pInstance = 0;@

          1 Reply Last reply
          0
          • A Offline
            A Offline
            alexander
            wrote on last edited by
            #13

            And why do you use std::wstring instead QString?

            1 Reply Last reply
            0
            • P Offline
              P Offline
              prakash02
              wrote on last edited by
              #14

              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.

              1 Reply Last reply
              0
              • D Offline
                D Offline
                DenisKormalev
                wrote on last edited by
                #15

                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.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  alexander
                  wrote on last edited by
                  #16

                  Denis Kormalev. :)

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    DenisKormalev
                    wrote on last edited by
                    #17

                    2moderators of this section: please move this thread to more correspondent category (Desktop I think)

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      alexander
                      wrote on last edited by
                      #18

                      prakash02, how do you defiine resource file of strings?

                      1 Reply Last reply
                      0
                      • P Offline
                        P Offline
                        prakash02
                        wrote on last edited by
                        #19

                        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.

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          alexander
                          wrote on last edited by
                          #20

                          try to use QObject::tr("") for strings instead string table in resource file.

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved