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] Splash Screen text depending on Main Window loading
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Splash Screen text depending on Main Window loading

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.7k Views 1 Watching
  • 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.
  • G Offline
    G Offline
    glararan
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Razamut
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        franku
        wrote on last edited by
        #3

        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?

        This, Jen, is the internet.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          glararan
          wrote on last edited by
          #4

          [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!

          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