Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    [SOLVED] Splash Screen text depending on Main Window loading

    General and Desktop
    3
    4
    1455
    Loading More Posts
    • 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
      glararan last edited by

      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 Reply Quote 0
      • R
        Razamut last edited by

        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 Reply Quote 0
        • F
          franku last edited by

          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 Reply Quote 0
          • G
            glararan last edited by

            [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 Reply Quote 0
            • First post
              Last post