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
QtWS25 Last Chance

QCommandLineParser print data to dos window

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 367 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 21 Jun 2024, 01:51 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

    J 1 Reply Last reply 21 Jun 2024, 05:15
    0
    • B Offline
      B Offline
      Bonnie
      wrote on 21 Jun 2024, 02:32 last edited by
      #2

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

      G 1 Reply Last reply 21 Jun 2024, 04:57
      0
      • B Bonnie
        21 Jun 2024, 02:32

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

        G Offline
        G Offline
        gong
        wrote on 21 Jun 2024, 04:57 last edited by
        #3

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

        B 1 Reply Last reply 21 Jun 2024, 06:00
        0
        • G gong
          21 Jun 2024, 01:51

          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

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 21 Jun 2024, 05:15 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
            21 Jun 2024, 04:57

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

            B Offline
            B Offline
            Bonnie
            wrote on 21 Jun 2024, 06:00 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 21 Jun 2024, 08:31
            0
            • B Bonnie
              21 Jun 2024, 06:00

              @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 21 Jun 2024, 08:31 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 24 Jun 2024, 02:56
              0
              • C Offline
                C Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on 21 Jun 2024, 10:50 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
                  21 Jun 2024, 08:31

                  @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 24 Jun 2024, 02:56 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 24 Jun 2024, 03:11 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

                    2/9

                    21 Jun 2024, 02:32

                    topic:navigator.unread, 7
                    • Login

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