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. Console settings
Forum Updated to NodeBB v4.3 + New Features

Console settings

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 4 Posters 3.0k Views 2 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.
  • R Rool

    Hello, everyone.
    Can someone tell me how do I get exit(return) code and message like "Press enter to close the window" in my console application using default Qt console(qtcreator_process_stub.exe)? 927d9271-0dcf-483f-a6f2-419e0e24209b-image.png
    Like in Visual Studio, for example:
    0f963589-b263-4544-8f74-df1b76c18a92-image.png

    Pl45m4P Offline
    Pl45m4P Offline
    Pl45m4
    wrote on last edited by Pl45m4
    #2

    @Rool

    QtCreator should write that line too.

    Do you have console in your .pro file?
    (Something like CONFIG += console)

    Is the "Run in terminal" option checked in your kit / run & build settings?
    https://doc.qt.io/qtcreator/creator-run-settings.html#specifying-run-settings-for-desktop-device-types


    If debugging is the process of removing software bugs, then programming must be the process of putting them in.

    ~E. W. Dijkstra

    R 1 Reply Last reply
    0
    • R Rool

      Hello, everyone.
      Can someone tell me how do I get exit(return) code and message like "Press enter to close the window" in my console application using default Qt console(qtcreator_process_stub.exe)? 927d9271-0dcf-483f-a6f2-419e0e24209b-image.png
      Like in Visual Studio, for example:
      0f963589-b263-4544-8f74-df1b76c18a92-image.png

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

      @Rool This "Press enter to close the window" is not printed by your application, but Visual Studio console. You can verify that if you start your app manually from cmd.exe. If you want to have this in your app you have to do it by yourself, there is no magic. Use std::cout and std::cin for that.

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

      R 1 Reply Last reply
      3
      • R Rool

        Hello, everyone.
        Can someone tell me how do I get exit(return) code and message like "Press enter to close the window" in my console application using default Qt console(qtcreator_process_stub.exe)? 927d9271-0dcf-483f-a6f2-419e0e24209b-image.png
        Like in Visual Studio, for example:
        0f963589-b263-4544-8f74-df1b76c18a92-image.png

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #4

        @Rool
        As @jsulm says for the messages (they are just being produced by the VS console, not your program).

        You also ask about the "exit code". I presume the Russian states your program "exited with code 0". That corresponds to your return 0 at the end of your main(). If you write a Qt program which runs another program like the one you show, or any other program, it can retrieve the exit code of that program via, say, int exitCode = QProcess::execute("someprogram.exe", QStringList()).

        R Pl45m4P 2 Replies Last reply
        0
        • Pl45m4P Pl45m4

          @Rool

          QtCreator should write that line too.

          Do you have console in your .pro file?
          (Something like CONFIG += console)

          Is the "Run in terminal" option checked in your kit / run & build settings?
          https://doc.qt.io/qtcreator/creator-run-settings.html#specifying-run-settings-for-desktop-device-types

          R Offline
          R Offline
          Rool
          wrote on last edited by
          #5

          @Pl45m4
          Yes, I have CONFIG += console c++11 in my .pro file and also option "Run in terminal" is Enabled.

          1 Reply Last reply
          0
          • jsulmJ jsulm

            @Rool This "Press enter to close the window" is not printed by your application, but Visual Studio console. You can verify that if you start your app manually from cmd.exe. If you want to have this in your app you have to do it by yourself, there is no magic. Use std::cout and std::cin for that.

            R Offline
            R Offline
            Rool
            wrote on last edited by
            #6

            @jsulm Yeah, I know, but I was thinking is there is an option to print this as Visual Studio console does. And also I've seen it is possible in Qt console: 26c2b732-8a3d-4d17-8829-37b9d654b236-image.png
            @jsulm said in Console settings:

            @Rool This "Press enter to close the window" is not printed by your application, but Visual Studio console.

            1 Reply Last reply
            0
            • JonBJ JonB

              @Rool
              As @jsulm says for the messages (they are just being produced by the VS console, not your program).

              You also ask about the "exit code". I presume the Russian states your program "exited with code 0". That corresponds to your return 0 at the end of your main(). If you write a Qt program which runs another program like the one you show, or any other program, it can retrieve the exit code of that program via, say, int exitCode = QProcess::execute("someprogram.exe", QStringList()).

              R Offline
              R Offline
              Rool
              wrote on last edited by Rool
              #7

              @JonB I'm sorry, maybe I didn't get what you want to say, but (=qtcreator_process_stub.exe it's not my custom program but the default Qt console. Yes, it's also the program, but I think I can manage it in another way.

              @JonB said in Console settings:

              @Rool
              If you write a Qt program which runs another program like the one you show

              JonBJ 1 Reply Last reply
              0
              • R Rool

                @JonB I'm sorry, maybe I didn't get what you want to say, but (=qtcreator_process_stub.exe it's not my custom program but the default Qt console. Yes, it's also the program, but I think I can manage it in another way.

                @JonB said in Console settings:

                @Rool
                If you write a Qt program which runs another program like the one you show

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #8

                @Rool
                You are getting hung up on what VS console is doing for you. qtcreator_process_stub.exe is just VS's own wrapper for executing your Qt console application. None of this exists outside of running your program from VS. Forget about what it does.

                • If you want to output the messages you see there, do e.g. your own cout << "Message". Or cin for reading characters.

                • The only point of the "exit code" stuff you see there is if you run a sub-process from your Qt program, and you want to get its return code. (Which is how the VS console is acting in this case.) For that I showed you how to do that from a Qt program. If you don't have that situation, then the return code is of no interest.

                1 Reply Last reply
                0
                • JonBJ JonB

                  @Rool
                  As @jsulm says for the messages (they are just being produced by the VS console, not your program).

                  You also ask about the "exit code". I presume the Russian states your program "exited with code 0". That corresponds to your return 0 at the end of your main(). If you write a Qt program which runs another program like the one you show, or any other program, it can retrieve the exit code of that program via, say, int exitCode = QProcess::execute("someprogram.exe", QStringList()).

                  Pl45m4P Offline
                  Pl45m4P Offline
                  Pl45m4
                  wrote on last edited by
                  #9

                  @JonB

                  I think, @Rool' s question is about QtCreator settings and not the program code as such.

                  I can confirm:

                  • Console project, with Qt in QtCreator (MinGW) -> no message.
                  • Raw C++ console project, no Qt (MinGW) -> "Press <Enter>... " message

                  Raw C++ pro - file

                  TEMPLATE = app
                  CONFIG += console c++11
                  CONFIG -= app_bundle
                  CONFIG -= qt
                  
                  SOURCES += \
                          main.cpp
                  

                  Qt console .pro - file

                  
                  QT -= gui
                  
                  CONFIG += c++11 console
                  CONFIG -= app_bundle
                  
                  # The following define makes your compiler emit warnings if you use
                  # any feature of Qt which as been marked deprecated (the exact warnings
                  # depend on your compiler). Please consult the documentation of the
                  # deprecated API in order to know how to port your code away from it.
                  DEFINES += QT_DEPRECATED_WARNINGS
                  
                  # You can also make your code fail to compile if you use deprecated APIs.
                  # In order to do so, uncomment the following line.
                  # You can also select to disable deprecated APIs only up to a certain version of Qt.
                  #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
                  
                  SOURCES += \
                          main.cpp
                  
                  # Default rules for deployment.
                  qnx: target.path = /tmp/$${TARGET}/bin
                  else: unix:!android: target.path = /opt/$${TARGET}/bin
                  !isEmpty(target.path): INSTALLS += target
                  
                  
                  

                  Cant say, if it's the pro - file or any other Run setting...


                  If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                  ~E. W. Dijkstra

                  R 1 Reply Last reply
                  1
                  • Pl45m4P Pl45m4

                    @JonB

                    I think, @Rool' s question is about QtCreator settings and not the program code as such.

                    I can confirm:

                    • Console project, with Qt in QtCreator (MinGW) -> no message.
                    • Raw C++ console project, no Qt (MinGW) -> "Press <Enter>... " message

                    Raw C++ pro - file

                    TEMPLATE = app
                    CONFIG += console c++11
                    CONFIG -= app_bundle
                    CONFIG -= qt
                    
                    SOURCES += \
                            main.cpp
                    

                    Qt console .pro - file

                    
                    QT -= gui
                    
                    CONFIG += c++11 console
                    CONFIG -= app_bundle
                    
                    # The following define makes your compiler emit warnings if you use
                    # any feature of Qt which as been marked deprecated (the exact warnings
                    # depend on your compiler). Please consult the documentation of the
                    # deprecated API in order to know how to port your code away from it.
                    DEFINES += QT_DEPRECATED_WARNINGS
                    
                    # You can also make your code fail to compile if you use deprecated APIs.
                    # In order to do so, uncomment the following line.
                    # You can also select to disable deprecated APIs only up to a certain version of Qt.
                    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
                    
                    SOURCES += \
                            main.cpp
                    
                    # Default rules for deployment.
                    qnx: target.path = /tmp/$${TARGET}/bin
                    else: unix:!android: target.path = /opt/$${TARGET}/bin
                    !isEmpty(target.path): INSTALLS += target
                    
                    
                    

                    Cant say, if it's the pro - file or any other Run setting...

                    R Offline
                    R Offline
                    Rool
                    wrote on last edited by
                    #10

                    @Pl45m4 said in Console settings:

                    Raw C++ console project, no Qt (MinGW) -> "Press <Enter>... " message

                    Created this one and still nothing

                    Pl45m4P 1 Reply Last reply
                    0
                    • R Rool

                      @Pl45m4 said in Console settings:

                      Raw C++ console project, no Qt (MinGW) -> "Press <Enter>... " message

                      Created this one and still nothing

                      Pl45m4P Offline
                      Pl45m4P Offline
                      Pl45m4
                      wrote on last edited by
                      #11

                      @Rool

                      What OS, QtCreator, Qt and compiler versions are you using?


                      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                      ~E. W. Dijkstra

                      R 1 Reply Last reply
                      0
                      • Pl45m4P Pl45m4

                        @Rool

                        What OS, QtCreator, Qt and compiler versions are you using?

                        R Offline
                        R Offline
                        Rool
                        wrote on last edited by Rool
                        #12

                        @Pl45m4 Windows 10, Qt Creator 4.13.2 (Community)(Basing on 5.15.1 MSVC 2019), Qt 5.15.1, tried different compilers but usually MSVC 2019 64-bit

                        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