[SOLVED] Splash Screen text depending on Main Window loading



  • Hello,
    I'm trying to change Splash Screen text when Main Window reach to line 'X'.

    main.cpp
    @Application::Application(int argc, char* argv[]) : QApplication(argc, argv), settings(new QSettings("applic"))
    {
    // ....

    QPixmap pixmap("splashScreen.png");
    
    SplashScreen* splash = new SplashScreen(pixmap);
    splash->setMessageRect(QRect::QRect(7, 253, 415, 14), Qt::AlignCenter);
    
    QFont splashFont;
    splashFont.setFamily("Arial");
    // .....
    
    splash->setFont(splashFont);
    splash->setWindowFlags(Qt::WindowStaysOnTopHint | Qt::SplashScreen);
    splash->show();
    
    splash->showStatusMessage("Initing...", QColor::fromRgb(255, 255, 255));
    
    MainWindow* mw = new MainWindow();
    
    connect(mw, SIGNAL(splashText(QString)), this, SLOT(setSplashText(QString)));
    
    mw->show();
    
    splash->finish(mw);
    

    }

    void Application::setSplashText(QString msg)
    {
    splash->showStatusMessage(msg, QColor::fromRgb(255, 255, 255));
    }

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

    return app.exec();
    

    }@

    mainwindow.cpp
    @MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow), centralWidget(new QWidget(this)), layout(new QGridLayout()), settings(new QSettings("applic")), dbHandler(new DatabaseHandler()), openASD(new OpenASD()), asdf(new ASDF()), qwer(new QWER())
    {
    // ......

    emit splashText("Set-up UI...");
    
    qDebug() << "waiting for sleeping";
    
    QThread sleep;
    sleep.sleep(2);
    
    qDebug() << "im waked!";
    
    ui->setupUi(this);
    
    // .......
    
    emit splashText("Set-up connects...");
    
    // ..........
    

    }@

    And to my problem... in MainWindow constructor i loading DB with about 15k querys, so it take while, but my splashText will not change because connect is in Application after constructor, so he can't check for changes, and this is my biggest problem. How to initialize with changing text and using other classes like OpenASD which is depending on MainWindow UI = OpenASD using Toolbar from MainWindow...

    Any solutions?

    Thank for reply.



  • What I did in my application was to give my MainWindow constructor a pointer to the spashscreen as argument and then use it to change splashscreen text.



  • The problem is that in your attempt the application's event handler app.exec() isn't started when you emit splashText(...).

    Why not call the splash->showMessage() directly?



  • [quote author="Razamut" date="1365782578"]What I did in my application was to give my MainWindow constructor a pointer to the spashscreen as argument and then use it to change splashscreen text.[/quote]
    Nice! Good idea, working!


Log in to reply
 

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