[SOLVED] Suppress the terminal console for my executable



  • When I run my (non-console) project in Qt Creator, I can control whether a console terminal is displayed or not, with a setting called "run in terminal". However when I run the executable outside Qt Creator, I always get the console displayed.

    I am using "testlib" in my project and I understood from this post that this could be what makes the console present:
    http://stackoverflow.com/questions/760323/why-does-my-qt4-5-app-open-a-console-window-under-windows

    However, I do want to stay with the "testlib" module for my unit testing, just want to not have the console. Is there any way to control this via my .pro file, or through the qmake / jom calls?



  • Hi,

    you can try adding this

    @CONFIG -= console@

    in your .pro file.



  • Thanks for the suggestion but that doesn't work.



  • Hi,

    can you post the structure of your project and your .pro file?



  • My .pro file looks like this.

    QT += core gui xml script network qml quick testlib
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    include ( C:\Qwt-6.1.0\features\qwt.prf )

    TARGET = MyApp
    TEMPLATE = app

    CONFIG -= silent
    CONFIG -= console

    LIBS += winmm.lib
    setupapi.lib \

    SOURCES +=
    MyApp.cpp
    ...

    HEADERS +=
    MyApp.h
    ...
    FORMS +=
    MyApp.ui
    ...
    RESOURCES +=
    MyApp.qrc



  • I eventually managed to get the behavior I wanted, with the help of this post: http://www.qtcentre.org/threads/31315-How-use-conditions-in-Qt-pro-file

    Basically, I now add a "CONFIG+=unittest" to my qmake call when I want the unit testing. Inside the .pro file, I have a conditional unittest scope in which I add the testlib, the source files related to unit testing and a DEFINE I use in my code. The only issue is that I have to rebuild to make sure switching between the normal and unit-testing mode works.

    Anyway - no more console when I don't need it and my code looks alright. Phew.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.