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. std::cout calls are eaten by Qt (nothing printed)

std::cout calls are eaten by Qt (nothing printed)

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 751 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.
  • MubinM Offline
    MubinM Offline
    Mubin
    wrote on last edited by
    #1

    Hi,
    I am experimenting with VulkanSceneGraph (a graphical library based on VulkanSDK ) and found a nice example with Qt integration. However, in the application, std::cout calls don't print anything at all. Maybe std::cout and std::cerr are redirected to somewhere by Qt, I don't know.
    How can I activate std::cout calls in Qt?
    All solutions that I found so far suggest enabling a flag in qmake file: CONFIG += console, but this project is CMake project.

    VulkanSDK Qt example repo:
    https://github.com/vsg-dev/vsgQt
    Related issue:
    https://github.com/vsg-dev/vsgQt/issues/35

    Thanks.

    JonBJ 1 Reply Last reply
    0
    • MubinM Mubin

      @JonB
      Yes it is a GUI program but before creating QApplication, std:cout should print to the console, right?

      For example I am adding a std::cout at this line: https://github.com/vsg-dev/vsgQt/blob/master/examples/vsgqtviewer/main.cpp#L76

      Even after creating QApplication until return application.exec(); it should print to console?

      When I run the program without any parameter, the error text at line https://github.com/vsg-dev/vsgQt/blob/master/examples/vsgqtviewer/main.cpp#L117 should print the error, right?

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #4

      @Mubin said in std::cout calls are eaten by Qt (nothing printed):

      Even after creating QApplication until return application.exec(); it should print to console?

      No, that's a property (WIN32) of the executable and has nothing to do with Qt

      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
      1
      • MubinM Mubin

        Hi,
        I am experimenting with VulkanSceneGraph (a graphical library based on VulkanSDK ) and found a nice example with Qt integration. However, in the application, std::cout calls don't print anything at all. Maybe std::cout and std::cerr are redirected to somewhere by Qt, I don't know.
        How can I activate std::cout calls in Qt?
        All solutions that I found so far suggest enabling a flag in qmake file: CONFIG += console, but this project is CMake project.

        VulkanSDK Qt example repo:
        https://github.com/vsg-dev/vsgQt
        Related issue:
        https://github.com/vsg-dev/vsgQt/issues/35

        Thanks.

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

        @Mubin
        Where do youm expect std::cout output to go, since I presume you have a GUI program? You might find them in Creator's "Output" window, but they are not going to go anywhere the user can see. If you want that you will want a "console" application, not a GUI one.

        MubinM 1 Reply Last reply
        0
        • JonBJ JonB

          @Mubin
          Where do youm expect std::cout output to go, since I presume you have a GUI program? You might find them in Creator's "Output" window, but they are not going to go anywhere the user can see. If you want that you will want a "console" application, not a GUI one.

          MubinM Offline
          MubinM Offline
          Mubin
          wrote on last edited by
          #3

          @JonB
          Yes it is a GUI program but before creating QApplication, std:cout should print to the console, right?

          For example I am adding a std::cout at this line: https://github.com/vsg-dev/vsgQt/blob/master/examples/vsgqtviewer/main.cpp#L76

          Even after creating QApplication until return application.exec(); it should print to console?

          When I run the program without any parameter, the error text at line https://github.com/vsg-dev/vsgQt/blob/master/examples/vsgqtviewer/main.cpp#L117 should print the error, right?

          Christian EhrlicherC 1 Reply Last reply
          0
          • MubinM Mubin

            @JonB
            Yes it is a GUI program but before creating QApplication, std:cout should print to the console, right?

            For example I am adding a std::cout at this line: https://github.com/vsg-dev/vsgQt/blob/master/examples/vsgqtviewer/main.cpp#L76

            Even after creating QApplication until return application.exec(); it should print to console?

            When I run the program without any parameter, the error text at line https://github.com/vsg-dev/vsgQt/blob/master/examples/vsgqtviewer/main.cpp#L117 should print the error, right?

            Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #4

            @Mubin said in std::cout calls are eaten by Qt (nothing printed):

            Even after creating QApplication until return application.exec(); it should print to console?

            No, that's a property (WIN32) of the executable and has nothing to do with Qt

            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
            1
            • MubinM Offline
              MubinM Offline
              Mubin
              wrote on last edited by
              #5

              Ok, I solved the problem.
              In Visual Studio, I changed the properties of the project.
              Properties -> Linker -> System -> SubSystem was set to Windows /SUBSYSTEM:WINDOWS), I set it to Console (/SUBSYSTEM:CONSOLE). It prints cout to the console now.
              Windows /SUBSYSTEM:WINDOWS) expects WinMain() instead of main().

              Christian EhrlicherC 1 Reply Last reply
              0
              • MubinM Mubin has marked this topic as solved on
              • MubinM Mubin

                Ok, I solved the problem.
                In Visual Studio, I changed the properties of the project.
                Properties -> Linker -> System -> SubSystem was set to Windows /SUBSYSTEM:WINDOWS), I set it to Console (/SUBSYSTEM:CONSOLE). It prints cout to the console now.
                Windows /SUBSYSTEM:WINDOWS) expects WinMain() instead of main().

                Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #6

                @Mubin That's whats the cmake property I linked is doing, yes.

                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
                0

                • Login

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