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. QApplication object construction time is too long
Qt 6.11 is out! See what's new in the release blog

QApplication object construction time is too long

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 2.1k Views 2 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.
  • joeQJ Offline
    joeQJ Offline
    joeQ
    wrote on last edited by
    #1

    I want to use the QSplashScreen. But i find QApplication a(argc,argv) or QtSingleApplication a(argc,argv) command take up too much time.

    First: I create new Qt Gui application to test the time. It was very good. just spend 1s;

    #include "mainwindow.h"
    #include <QApplication>
    #include <QSplashScreen>
    #include <QThread>
    #include <QTime>
    #include <QDebug>
    
    int main(int argc, char *argv[])
    {
        qDebug() << "0--" << QTime::currentTime();///< 0-- QTime("18:11:00.998")
        QApplication a(argc, argv);
        qDebug() << "1--" << QTime::currentTime();///< 1-- QTime("18:11:01.192")
    
        QPixmap pixmap(":/png/time.jpg");
        QSplashScreen splash(pixmap);
        splash.show();
    
        a.processEvents();
    
        MainWindow w;
    
        QThread::sleep(5);
    
        w.show();
    
        splash.finish(&w);
        return a.exec();
    }
    

    Second: I test the time in my qt project now. using the QApplication it was spent 12s;

    #include "mainwindow.h"
    #include <QApplication>
    #include <QTime>
    #include <QDebug>
    
    int main(int argc, char *argv[])
    {
        qDebug() << "0--" << QTime::currentTime(); ///< 0-- QTime("18:20:28.031")
        QApplication a(argc,argv);
        qDebug() << "1--" << QTime::currentTime(); ///< 1-- QTime("18:20:40.122")
    
        MainWindow w;
        w.show();
    
        return a.exec();
    }
    
    

    Last: Because i used the QtSingleApplication. I doubt it. But, using the time is same with QApplication both about 12s.

    #include "module_singleApp/qtsingleapplication.h"
    #include "mainwindow.h"
    #include <QTime>
    #include <QDebug>
    
    #ifndef JOE
    int main(int argc, char *argv[])
    {
        qDebug() << "0--" << QTime::currentTime(); ///< 0-- QTime("18:24:19.141")
        QtSingleApplication a(argc, argv);
        qDebug() << "1--" << QTime::currentTime(); ///< 1-- QTime("18:24:31.316")
    
        if(a.sendMessage("Wake up!")){
            return 0;   ///<Not allow to use the goto
        }
    
        MainWindow w;
        a.setActivationWindow(&w);
    
        w.show();
    
        return a.exec();
    }
    

    I guest the reason maybe is the load some dll and lib files in my pro file.

    I just want to use the QSplashScreen in my main.cpp file. But, QApplication construct takes up too much time.

    I also test with release. also takes up too much time.

    -_-!...

    Just do it!

    1 Reply Last reply
    0
    • E Offline
      E Offline
      eti_nne
      wrote on last edited by
      #2

      Both QGuiAppliaction and QApplication example are using a QApplication. Are you sure about those example ?

      QSingleApplication doesn't seem to be part of the official Qt distribution. It might use deprecated functions. In my opinion, do not use it.

      Do you pass any argument to your program ?

      What is your system context ?

      joeQJ 1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        @eti_nne QtSingleApplication is part of the QtSolutions module. Even if a bit old it's still used in e.g. Qt Creator.

        @joeQ What version of Qt are you talking about ? On what OS ? What's the load of your system ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        joeQJ 2 Replies Last reply
        0
        • E eti_nne

          Both QGuiAppliaction and QApplication example are using a QApplication. Are you sure about those example ?

          QSingleApplication doesn't seem to be part of the official Qt distribution. It might use deprecated functions. In my opinion, do not use it.

          Do you pass any argument to your program ?

          What is your system context ?

          joeQJ Offline
          joeQJ Offline
          joeQ
          wrote on last edited by
          #4

          @eti_nne

          Why i used the QtSingleApplication in my project, because i want QtSingleApplication component provides for applications that can be only started once by user.

          But, i found QtSingleApplication construct take up too much time.

          Just do it!

          1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            @eti_nne QtSingleApplication is part of the QtSolutions module. Even if a bit old it's still used in e.g. Qt Creator.

            @joeQ What version of Qt are you talking about ? On what OS ? What's the load of your system ?

            joeQJ Offline
            joeQJ Offline
            joeQ
            wrote on last edited by
            #5

            @SGaist

            Qt version 5.7.0
            Window

            In my pro file. i has some lib and dll files to link or load.

            Just do it!

            1 Reply Last reply
            0
            • SGaistS SGaist

              Hi,

              @eti_nne QtSingleApplication is part of the QtSolutions module. Even if a bit old it's still used in e.g. Qt Creator.

              @joeQ What version of Qt are you talking about ? On what OS ? What's the load of your system ?

              joeQJ Offline
              joeQJ Offline
              joeQ
              wrote on last edited by
              #6

              @SGaist

              I want to use the QSplashScreen provides a splash screen that can be shown during application startup. but, i found QtSingleApplication a(argc,argv) command takes up too much time.

              If i use QSplashScreen, must be after QtSingleApplication.

              How to save it?

              Just do it!

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Window is a bit vague, it can range from XP to 10.

                What dependencies do you have ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                joeQJ 2 Replies Last reply
                0
                • SGaistS SGaist

                  Window is a bit vague, it can range from XP to 10.

                  What dependencies do you have ?

                  joeQJ Offline
                  joeQJ Offline
                  joeQ
                  wrote on last edited by
                  #8

                  @SGaist

                  what your mean maybe it was the system problem? Wait a moment, i try again. project in the company. i am at home now. ok, i will try the QtSingleApplication in my win10. Wait a moment.

                  Just do it!

                  1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Window is a bit vague, it can range from XP to 10.

                    What dependencies do you have ?

                    joeQJ Offline
                    joeQJ Offline
                    joeQ
                    wrote on last edited by
                    #9

                    @SGaist

                    I download the QtSingleapplication source code test again in my win10. it takes up time less than 1s. very fast.

                    probably because of a systeam problem or others.

                    Ok, The problem pause.

                    Just do it!

                    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