Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved]shows splashscreen but does not show its message
QtWS25 Last Chance

[solved]shows splashscreen but does not show its message

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 5.1k 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.
  • T Offline
    T Offline
    tunde
    wrote on last edited by
    #1

    i created a splashscreen for my application; however, it shows the splashscreen and then disappears but it does not show its message like loading modules and establish connections through the showMessage(). why?

    attached is my code

    @
    #include <QtGui/QApplication>
    #include "mobile.h"
    #include <QSplashScreen>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);

    QPixmap pixmap(":/images/mobile.jpg");
     QSplashScreen *splash = new QSplashScreen(pixmap);
     splash->show();
     a.processEvents();
    
    
    
     //Qt::Alignment topRight = Qt::AlignRight | Qt::AlignTop;
        splash->showMessage("Setting up the main window...");
                               //topRight, Qt::white);
    

    a.processEvents();
    splash->showMessage("Loading modules...");
    //topRight, Qt::white);

    a.processEvents();

            splash->showMessage("Establishing connections...");
                                   //topRight, Qt::white);
    

    a.processEvents();

    mobile w;
    w.show();
    splash->finish(&w);
    delete splash;
    
    
    return a.exec(&#41;;
    

    }
    @

    [edit: Code highlighted / Denis Kormalev]

    1 Reply Last reply
    0
    • I Offline
      I Offline
      IrQX
      wrote on last edited by
      #2

      bad formating, making code hard to understand.

      1 Reply Last reply
      0
      • I Offline
        I Offline
        IrQX
        wrote on last edited by
        #3

        BTW, working sample:

        But, i used QScoperPointer. You can replace it to standart pointer or non-pointer class instance.

        @QApplication app(argc, argv);

        QScopedPointer<QSplashScreen> splash(new QSplashScreen(QPixmap(":/splash")));
        splash->show();
        splash->showMessage(QSplashScreen::tr("Loading..."), Qt::AlignBottom | Qt::AlignHCenter, Qt::black);
        app.processEvents();
        

        // some code

        splash->showMessage(QSplashScreen::tr("Settings Manager: loading saved settings"), Qt::AlignBottom | Qt::AlignHCenter, Qt::black);
        app.processEvents();
        

        // loading settings

        splash->showMessage(QSplashScreen::tr("Plugin Manager: loading plugins"), Qt::AlignBottom | Qt::AlignHCenter, Qt::black);
        app.processEvents();
        

        // loading plugins

        MainWindow w;
        w.setWindowTitle(app.applicationName());
        w.showMaximized();
        splash->finish(&w);
        int rslt = app.exec(); @
        
        1 Reply Last reply
        0
        • T Offline
          T Offline
          tunde
          wrote on last edited by
          #4

          i tried ur sample code; however, it still does not show the message on the splashscreen

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giesbert
            wrote on last edited by
            #5

            Hi,
            I took the code and added a sleep, as the comments for do some stuff will not take time :-)
            This code shows the texts:
            @/**

            • this class is used to call sleep, as msleep is a protected function of QThread
              /
              class CxTestSleepThread : public QThread
              {
              public:
              /
              *
              • this method is used to call sleep, as msleep is a protected function of
              • QThread
              • @param nMSecs milliseconds to sleep
                */
                static void mySleep(int nMSecs)
                {
                msleep(nMSecs);
                }
                };

            int main(int argc, char *argv[])
            {
            QApplication app(argc, argv);

            QScopedPointer<QSplashScreen> splash(new QSplashScreen(QPixmap(":/splash")));
            splash->show();
            splash->showMessage(QSplashScreen::tr("Loading..."), Qt::AlignBottom | Qt::AlignHCenter, Qt::white);
            app.processEvents();
            
            CxTestSleepThread::mySleep(500);
            // some code
            
            splash->showMessage(QSplashScreen::tr("Settings Manager: loading saved settings"), Qt::AlignBottom | Qt::AlignHCenter, Qt::white);
            app.processEvents();
            
            CxTestSleepThread::mySleep(500);
            // loading settings
            
            splash->showMessage(QSplashScreen::tr("Plugin Manager: loading plugins"), Qt::AlignBottom | Qt::AlignHCenter, Qt::white);
            app.processEvents();
            
            CxTestSleepThread::mySleep(500);
            // loading plugins
            
            MainWindow w;
            w.setWindowTitle(app.applicationName());
            w.showMaximized();
            splash->finish(&w);
            return app.exec();
            

            }
            @

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

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

              Maybe you are just showing black text on a black splashscreen?

              1 Reply Last reply
              0
              • I Offline
                I Offline
                IrQX
                wrote on last edited by
                #7

                [quote author="Denis Kormalev" date="1290689201"]Maybe you are just showing black text on a black splashscreen?[/quote]

                Yeah, seems to be truth

                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