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. QCommandLineParser print data to dos window
Forum Update on Monday, May 27th 2025

QCommandLineParser print data to dos window

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 380 Views
  • 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.
  • G Offline
    G Offline
    gong
    wrote on last edited by
    #1

    Hello everyone,

    I am the beginner of Qt development, my Qt version is 6.6.3.I try to make my application to run batch.
    The QCommandLineParser work well but cannot print any data to dos window. My code as below: qDebug print nothing but QMessageBox show normally. And the version, help command(-v , -h )will show the data in new window, not in dos window.

    Is there any advice to show the data in dos window? Thank a lot!

    屏幕截图 2024-06-21 093542.png

    jsulmJ 1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by
      #2

      Is your application supposed to be a console application or a gui application?

      G 1 Reply Last reply
      0
      • B Bonnie

        Is your application supposed to be a console application or a gui application?

        G Offline
        G Offline
        gong
        wrote on last edited by
        #3

        @Bonnie thanks for your reply, it is the gui application.

        B 1 Reply Last reply
        0
        • G gong

          Hello everyone,

          I am the beginner of Qt development, my Qt version is 6.6.3.I try to make my application to run batch.
          The QCommandLineParser work well but cannot print any data to dos window. My code as below: qDebug print nothing but QMessageBox show normally. And the version, help command(-v , -h )will show the data in new window, not in dos window.

          Is there any advice to show the data in dos window? Thank a lot!

          屏幕截图 2024-06-21 093542.png

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

          @gong In future please post code as text, not pictures.
          Do you start your application from a terminal (cmd.exe) or from QtCreator?
          You can also set "Run in terminal" checkbox in Run settings of your project in "Build & Run" in QtCreator.

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

          1 Reply Last reply
          0
          • G gong

            @Bonnie thanks for your reply, it is the gui application.

            B Offline
            B Offline
            Bonnie
            wrote on last edited by Bonnie
            #5

            @gong gui application doesn't have console output by default on windows.
            Try add win32:CONFIG += console in your .pro file.
            If you uses cmake, I've searched what's the equivalent, seems if you create a gui project by qt creator wizard, WIN32_EXECUTABLE TRUE is set in set_target_properties automatically and it should be removed to have console feature.

            G 1 Reply Last reply
            0
            • B Bonnie

              @gong gui application doesn't have console output by default on windows.
              Try add win32:CONFIG += console in your .pro file.
              If you uses cmake, I've searched what's the equivalent, seems if you create a gui project by qt creator wizard, WIN32_EXECUTABLE TRUE is set in set_target_properties automatically and it should be removed to have console feature.

              G Offline
              G Offline
              gong
              wrote on last edited by
              #6

              @Bonnie @jsulm Thank you very much for the help! The issue is solved.
              After adding "CONFIG+=console", start application from cmd, qDebug will print in the dos window. But it print so many now, is it possilbe to control, for example, print qInfo only and ignore the others, I just want to show the key results(one or several line) in dos window.

              B 1 Reply Last reply
              0
              • Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #7

                See https://doc.qt.io/qt-6/qtlogging.html#qInstallMessageHandler on how to filter and format the debug output.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                2
                • G gong

                  @Bonnie @jsulm Thank you very much for the help! The issue is solved.
                  After adding "CONFIG+=console", start application from cmd, qDebug will print in the dos window. But it print so many now, is it possilbe to control, for example, print qInfo only and ignore the others, I just want to show the key results(one or several line) in dos window.

                  B Offline
                  B Offline
                  Bonnie
                  wrote on last edited by
                  #8

                  @gong One simple but not so ideal solution is adding DEFINES_RELEASE += QT_NO_DEBUG_OUTPUT in the .pro file.
                  Then qDebug() will only print in the debug version, not the release one.

                  1 Reply Last reply
                  1
                  • G Offline
                    G Offline
                    gong
                    wrote on last edited by
                    #9

                    Thanks a lot! I use the "qInstallMessageHandler" to solve the issue and show the printed result in dos window. I think the topic is finished perfectlly and thank you for the help, BTW how to set the topic as solved?

                    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