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. Qt application removes CMD when it runs independently
Forum Updated to NodeBB v4.3 + New Features

Qt application removes CMD when it runs independently

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 4 Posters 1.4k 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.
  • Qt_crazyerQ Offline
    Qt_crazyerQ Offline
    Qt_crazyer
    wrote on last edited by
    #1

    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 call

    QTest:: 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.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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 ?

      Qt_crazyerQ 1 Reply Last reply
      1
      • mrjjM mrjj

        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 ?

        Qt_crazyerQ Offline
        Qt_crazyerQ Offline
        Qt_crazyer
        wrote on last edited by
        #3

        @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.

        mrjjM jsulmJ 2 Replies Last reply
        0
        • Qt_crazyerQ Qt_crazyer

          @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.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Qt_crazyer
          But have you tested that removing qWait() also removes the
          console window?

          1 Reply Last reply
          0
          • Qt_crazyerQ Qt_crazyer

            @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.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Qt_crazyer Remove

            QT       += testlib
            

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            mrjjM 1 Reply Last reply
            1
            • jsulmJ jsulm

              @Qt_crazyer Remove

              QT       += testlib
              
              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @jsulm
              and then also QTest:: qWait () , i assume ? or ?

              jsulmJ 1 Reply Last reply
              0
              • mrjjM mrjj

                @jsulm
                and then also QTest:: qWait () , i assume ? or ?

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @mrjj Yes, there are better ways to wait (if you really want to) :-)

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                mrjjM 1 Reply Last reply
                1
                • jsulmJ jsulm

                  @mrjj Yes, there are better ways to wait (if you really want to) :-)

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @jsulm
                  100% agree. :)
                  Well QThread::wait wont work the same so i guess some refactoring is needed to
                  work again without QTest

                  Qt_crazyerQ 1 Reply Last reply
                  0
                  • mrjjM mrjj

                    @jsulm
                    100% agree. :)
                    Well QThread::wait wont work the same so i guess some refactoring is needed to
                    work again without QTest

                    Qt_crazyerQ Offline
                    Qt_crazyerQ Offline
                    Qt_crazyer
                    wrote on last edited by
                    #9

                    @mrjj
                    I rewrote a function with QTimer for a delay of time. Remove the testlib. Now it works well, without the console.
                    Thanks you.

                    aha_1980A 1 Reply Last reply
                    2
                    • Qt_crazyerQ Qt_crazyer

                      @mrjj
                      I rewrote a function with QTimer for a delay of time. Remove the testlib. Now it works well, without the console.
                      Thanks you.

                      aha_1980A Offline
                      aha_1980A Offline
                      aha_1980
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @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 :)

                      Qt has to stay free or it will die.

                      1 Reply Last reply
                      1

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved