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. [SOLVED] Suppress the terminal console for my executable
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Suppress the terminal console for my executable

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.6k Views 1 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.
  • F Offline
    F Offline
    frankiefrank
    wrote on last edited by
    #1

    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?

    "Roads? Where we're going, we don't need roads."

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      Hi,

      you can try adding this

      @CONFIG -= console@

      in your .pro file.

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      0
      • F Offline
        F Offline
        frankiefrank
        wrote on last edited by
        #3

        Thanks for the suggestion but that doesn't work.

        "Roads? Where we're going, we don't need roads."

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mcosta
          wrote on last edited by
          #4

          Hi,

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

          Once your problem is solved don't forget to:

          • Mark the thread as SOLVED using the Topic Tool menu
          • Vote up the answer(s) that helped you to solve the issue

          You can embed images using (http://imgur.com/) or (http://postimage.org/)

          1 Reply Last reply
          0
          • F Offline
            F Offline
            frankiefrank
            wrote on last edited by
            #5

            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

            "Roads? Where we're going, we don't need roads."

            1 Reply Last reply
            0
            • F Offline
              F Offline
              frankiefrank
              wrote on last edited by
              #6

              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.

              "Roads? Where we're going, we don't need roads."

              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