Splash Screen



  • Hi sir...,

              Am unable to display splash screen in Qt 4.8.4, in beagle board...Please help me...here is my code..
    

    @
    #include "mainwindow.h"
    #include <QApplication>
    #include <QSplashScreen>
    #include <QTimer>
    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    QSplashScreen *splash = new QSplashScreen;
    splash->setPixmap(QPixmap("/home/shirisha/Documents/images.jpeg"));
    splash->show();
    MainWindow w;
    QTimer::singleShot(2500,splash,SLOT(close()));
    QTimer::singleShot(2500,&w,SLOT(show()));

    // w.show();

    return a.exec(&#41;;
    

    }
    @

    [edit: added missing coding tags @ SGaist]



  • Hi Shirisha,

    I don't see the slot mentioned in
    @QTimer::singleshot()
    @

    For example:
    @
    #include <QApplication>
    #include <QTimer>

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    QTimer::singleShot(600000, &app, SLOT(quit()));
    ...
    return app.exec();
    }
    @

    "Link to Qt documentation":http://qt-project.org/doc/qt-4.8/qtimer.html#singleShot

    And may I ask, what is the real reason for using QTimer? Are you processing the program or application related files when you want to display splash screen?



  • no sir i menstioned ther bt in the post unable to write..the same thing i menstoned like...

    QTimer::singleShot(2500, splash, SLOT(close()));
    QTimer::singleShot(2500, &app, SLOT(show()));



  • May be as a quick test, can you try this code?

    @
    #include <QApplication>
    #include <QPixmap>
    #include <QSplashScreen>
    #include <QWidget>
    #include <QMainWindow>
    #include <QTimer>
    #include <QThread>

    class I : public QThread
    {
    public:
    static void sleep(unsigned long secs) {
    QThread::sleep(secs);
    }
    };

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

    QApplication app(argc, argv);
    // change this file path
    QPixmap pixmap("c://paris.png"); // Insert your splash page image here
    QSplashScreen splash(pixmap);
    splash.show();

    splash.showMessage(QObject::tr("Loading Programs........."),
    Qt::AlignLeft | Qt::AlignTop, Qt::black); //This line represents the alignment of text, color and position

    qApp->processEvents(); //This is used to accept a click on the screen so that user can cancel the screen

    QMainWindow mainWin;
    mainWin.setWindowTitle("Qt Application"); //Set the title of your main Qt Application
    mainWin.resize(600, 500);
    I::sleep(5); // Splash page is shown for 5 seconds

    mainWin.show(); //This will maximize to fullscreen the size of your application window after the splash page displays
    splash.finish(&mainWin);
    return app.exec();
    }
    @

    Please note: Update the image path with yours
    @
    ”/home/shirisha/Documents/images.jpeg”
    @

    And just to sure, what is the file details of the images.jpeg?

    Thanks!


Log in to reply