QApplication object construction time is too long
-
I want to use the
QSplashScreen
. But i findQApplication a(argc,argv)
orQtSingleApplication 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 withQApplication
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.
-_-!...
-
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 ?
-
-
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. -
-
I want to use the
QSplashScreen
provides a splash screen that can be shown during application startup. but, i foundQtSingleApplication a(argc,argv)
command takes up too much time.If i use
QSplashScreen
, must be afterQtSingleApplication
.How to save it?
-
Window is a bit vague, it can range from XP to 10.
What dependencies do you have ?
-
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. -
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.