[solved]shows splashscreen but does not show its message



  • 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]



  • bad formating, making code hard to understand.



  • 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(); @


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



  • 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();
    

    }
    @



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



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

    Yeah, seems to be truth


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.