Solved Qt application removes CMD when it runs independently
-
After packing programs in release mode, every running program always opens the Windows console before the display of my program. How should I close the console?
I learned that this might be related to my use of testlib. Because in my application, I callQTest:: qWait ();
I don't know how to correctly modify the pro file, here is it:
QT += core gui QT += testlib QT += multimedia greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = iass TEMPLATE = app DEFINES += QT_DEPRECATED_WARNINGS DEFINES += QT_MESSAGELOGCONTEXT CONFIG += mobility RESOURCES += \ image.qrc RC_ICONS = Password.ico SOURCES += \ main.cpp \ mainwindow.cpp HEADERS += \ mainwindow.h
Qt Creator 5.9.1 on windows10
MSVC2015 64bit complier
Thanks for any advice. -
Hi
well you have template = app
so it seems not to be a console app.
QTest:: qWait () is for unit testing. (normally)What do you need qWait for ?
-
@mrjj
My application is a Qt Widgets Application.
I use the qWait just for a delay of time. I don't know much about unit testing. -
@Qt_crazyer
But have you tested that removing qWait() also removes the
console window? -
@Qt_crazyer Remove
QT += testlib
-
@jsulm
and then also QTest:: qWait () , i assume ? or ? -
@mrjj Yes, there are better ways to wait (if you really want to) :-)
-
@jsulm
100% agree. :)
Well QThread::wait wont work the same so i guess some refactoring is needed to
work again without QTest -
@mrjj
I rewrote a function with QTimer for a delay of time. Remove the testlib. Now it works well, without the console.
Thanks you. -
@Qt_crazyer said in Qt application removes CMD when it runs independently:
@mrjj
I rewrote a function with QTimer for a delay of time. Remove the testlib. Now it works well, without the console.and by the way, a timer is much better than a delay :)