Indicator of loading of the annex in Qt



  • How to add a load indicator QApplication?

    int main( int argc, char** argv )
    {
      QApplication app( argc, argv );
      // старт
      ...
      mainwindow->show();
      // завершение
      int res = app.exec();
      delete mainwindow;
      return res;
    }
    

    Once established app Start displaying progress bar or other download indicator, and when the mainwindow is completed and downloaded, complete the display. I tried through. QSplashSreen♪ Example of documentation outlet

    int main(int argc, char *argv[])
     {
         QApplication app(argc, argv);
         QPixmap pixmap(":/splash.png");
         QSplashScreen splash(pixmap);
         splash.show();
         app.processEvents();
         ...
         QMainWindow window;
         window.show();
         splash.finish(&window);
         return app.exec();
     }
    

    My example is:

    int main( int argc, char** argv )
    {
      QApplication app( argc, argv );
      QPixmap pixmap(":/splash.gif");
      QSplashScreen splash(pixmap);
      splash.show();
      app.processEvents();
      // старт
      ...
      mainwindow->show();
      // завершение
      splash.finish(mainwindow);
      int res = app.exec();
      delete mainwindow;
      return res;
    }
    

    First, instead *.gif There's a gray square of the same size, then the image is downloaded only when it's already opened. mainwindow♪ No animation.

    Updating: attempts to make a separate class from QSplashScreenor inherited from QThread - i.e. a separate flow - and communicate through the signal-plate while the failures are over, the same effect, the schedule is not displayed until it is completed app.exec()



  • According to the code, your chain of action is in the GUI flow. But as long as it's done, the GUI-stream can't handle events, including events of refill. The exit is the implementation of a chain of action in a separate flow. After receiving a signal from him finished, GUI may continue its work and display it MainWindow

    The second option of addressing the challenge might be a challenge. QApplication::processEvents() inside the initialization code. But it's not a good decision, and there's a risk of fries, i.e., a graphic interface, if between processEvents It's time for the user.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2