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 Creator FC23 New Install - No Console Output
Forum Updated to NodeBB v4.3 + New Features

Qt Creator FC23 New Install - No Console Output

Scheduled Pinned Locked Moved General and Desktop
22 Posts 5 Posters 9.2k Views 3 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.
  • Ni.SumiN Offline
    Ni.SumiN Offline
    Ni.Sumi
    wrote on last edited by Ni.Sumi
    #10

    hi @Shadders ,

    AFAIK, you can't specify the using namespace std in Qt application, which is incompatible with the MockCompiler.

    When it comes to the GUI Based application, Qt sugguest to use QDebug .

    Eg:: #include <QDebug>
    --------------------
    in code.. qDebug() <<"Somehting "; // it will print out like std::cout and powerful than this

    ShaddersS 1 Reply Last reply
    1
    • Ni.SumiN Ni.Sumi

      hi @Shadders ,

      AFAIK, you can't specify the using namespace std in Qt application, which is incompatible with the MockCompiler.

      When it comes to the GUI Based application, Qt sugguest to use QDebug .

      Eg:: #include <QDebug>
      --------------------
      in code.. qDebug() <<"Somehting "; // it will print out like std::cout and powerful than this

      ShaddersS Offline
      ShaddersS Offline
      Shadders
      wrote on last edited by
      #11

      @Ni.Sumi
      Hi Ni.Sumi,

      Thanks for the guidance, much appreciated.

      I will examine the QDebug aspect - this may be mentioned later in the book.

      Thanks and regards,

      Shadders.

      kshegunovK 1 Reply Last reply
      0
      • ShaddersS Offline
        ShaddersS Offline
        Shadders
        wrote on last edited by
        #12

        Hi,

        As an update - the

        using namespace std;
        

        does work - i played about with the code and all that was required was the endl or flush codeword.

        endl places as return as expected, flush outputs the line to console without the return.

        Thanks and regards,

        Shadders.

        jsulmJ 1 Reply Last reply
        0
        • ShaddersS Shadders

          Hi,

          As an update - the

          using namespace std;
          

          does work - i played about with the code and all that was required was the endl or flush codeword.

          endl places as return as expected, flush outputs the line to console without the return.

          Thanks and regards,

          Shadders.

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

          @Shadders I think the std::flush is needed because just after printing the strinig to the standard output you start the Qt event loop (a.exec()). Standard output is buffered, so you do not know exactly when the buffer is really printed. It looks like sometimes starting event loop prevents the buffer from being flushed.

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

          1 Reply Last reply
          3
          • ShaddersS Shadders

            @Ni.Sumi
            Hi Ni.Sumi,

            Thanks for the guidance, much appreciated.

            I will examine the QDebug aspect - this may be mentioned later in the book.

            Thanks and regards,

            Shadders.

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #14

            @Shadders
            @jsulm is correct. The standard output is a file, and as pretty much any file it is buffered. So you need to explicitly flush the contents sitting in the buffer to see what's been printed. std::endl will do the flush implicitly after adding the newline. This is not a Qt specific thing (to answer your other question), it applies to non-qt applications as well.

            On a related note, if you want a "Qt solution" for writing to the standard output, you can use QTextStream, like this:

            QTextStream cout(stdout);
            cout << "Test string" << endl;
            

            this doesn't require to expand the std namespace, or include <iostream>.

            @Ni-Sumi said:

            AFAIK, you can't specify the using namespace std in Qt application, which is incompatible with the MockCompiler.

            You can. moc doesn't care about the namespaces. The only issue with using namespace std; is the global namespace pollution it introduces, but it's perfectly safe to use it (especially in source files).

            When it comes to the GUI Based application, Qt sugguest to use QDebug .

            Only, and I can't emphasize this enough, for debugging purposes! You shouldn't rely on qDebug for production code.

            Kind regards.

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply
            2
            • ShaddersS Offline
              ShaddersS Offline
              Shadders
              wrote on last edited by Shadders
              #15

              Hi jsulm, kshegubnov

              Thanks for the extra feedback, much appreciated.

              I tried the qDebug function and this does not work for my installation of Fedora 23.

              Code i have tried is :

              qDebug("6! is %d   \n", MathFunctions::factorial(6));
              
              qDebug() << "6! is " << MathFunctions::factorial(6);
              
              qDebug() << "6! is " << MathFunctions::factorial(6) << endl;
              

              and

              cout << "6! is " << MathFunctions::factorial(6) << "\n";
              

              The cout version works, but the qDebug version does not print to the console. I replaced the function factorial with a unsigned integer variable, and the same result - no output.

              The qDebug example i have used is from the tutorial book - with the third myself adding the endl.

              The code compiles ok, and i am using v5.6 of QT Creator.

              As such, for the qDebug option, there is no console output.

              I have a bug raised with Fedora bugzilla on the library qtdeclarations-devel and qtquickcontrols2 library/package issue - but i do not think that is the issue here.

              Any ideas on the console output issues i am experiencing ?

              Thanks and regards,

              Shadders.

              kshegunovK ? 2 Replies Last reply
              0
              • jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #16

                That's strange. For me it is working on Ubuntu.
                Do you have CONFIG += console in your PRO file?

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

                ShaddersS 1 Reply Last reply
                1
                • ShaddersS Shadders

                  Hi jsulm, kshegubnov

                  Thanks for the extra feedback, much appreciated.

                  I tried the qDebug function and this does not work for my installation of Fedora 23.

                  Code i have tried is :

                  qDebug("6! is %d   \n", MathFunctions::factorial(6));
                  
                  qDebug() << "6! is " << MathFunctions::factorial(6);
                  
                  qDebug() << "6! is " << MathFunctions::factorial(6) << endl;
                  

                  and

                  cout << "6! is " << MathFunctions::factorial(6) << "\n";
                  

                  The cout version works, but the qDebug version does not print to the console. I replaced the function factorial with a unsigned integer variable, and the same result - no output.

                  The qDebug example i have used is from the tutorial book - with the third myself adding the endl.

                  The code compiles ok, and i am using v5.6 of QT Creator.

                  As such, for the qDebug option, there is no console output.

                  I have a bug raised with Fedora bugzilla on the library qtdeclarations-devel and qtquickcontrols2 library/package issue - but i do not think that is the issue here.

                  Any ideas on the console output issues i am experiencing ?

                  Thanks and regards,

                  Shadders.

                  kshegunovK Offline
                  kshegunovK Offline
                  kshegunov
                  Moderators
                  wrote on last edited by
                  #17

                  @Shadders
                  I also see the qDebug output on Debian. Perhaps it's redirected to the application output window, could you check that?

                  PS.
                  Sorry for the late reply, I only just received the notification ... very strange.

                  Read and abide by the Qt Code of Conduct

                  ShaddersS 1 Reply Last reply
                  0
                  • ShaddersS Shadders

                    Hi jsulm, kshegubnov

                    Thanks for the extra feedback, much appreciated.

                    I tried the qDebug function and this does not work for my installation of Fedora 23.

                    Code i have tried is :

                    qDebug("6! is %d   \n", MathFunctions::factorial(6));
                    
                    qDebug() << "6! is " << MathFunctions::factorial(6);
                    
                    qDebug() << "6! is " << MathFunctions::factorial(6) << endl;
                    

                    and

                    cout << "6! is " << MathFunctions::factorial(6) << "\n";
                    

                    The cout version works, but the qDebug version does not print to the console. I replaced the function factorial with a unsigned integer variable, and the same result - no output.

                    The qDebug example i have used is from the tutorial book - with the third myself adding the endl.

                    The code compiles ok, and i am using v5.6 of QT Creator.

                    As such, for the qDebug option, there is no console output.

                    I have a bug raised with Fedora bugzilla on the library qtdeclarations-devel and qtquickcontrols2 library/package issue - but i do not think that is the issue here.

                    Any ideas on the console output issues i am experiencing ?

                    Thanks and regards,

                    Shadders.

                    ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by A Former User
                    #18

                    @Shadders Look at this and blame Fedora: https://forum.qt.io/topic/54820

                    kshegunovK ShaddersS 2 Replies Last reply
                    1
                    • ? A Former User

                      @Shadders Look at this and blame Fedora: https://forum.qt.io/topic/54820

                      kshegunovK Offline
                      kshegunovK Offline
                      kshegunov
                      Moderators
                      wrote on last edited by
                      #19

                      @Wieland
                      Smart people those fedora guys ... :D

                      Read and abide by the Qt Code of Conduct

                      1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        That's strange. For me it is working on Ubuntu.
                        Do you have CONFIG += console in your PRO file?

                        ShaddersS Offline
                        ShaddersS Offline
                        Shadders
                        wrote on last edited by
                        #20

                        @jsulm
                        Hi jsulm,

                        Thanks - yes have that directive in the .PRO file. Thanks.

                        Regards,

                        Shadders.

                        1 Reply Last reply
                        0
                        • kshegunovK kshegunov

                          @Shadders
                          I also see the qDebug output on Debian. Perhaps it's redirected to the application output window, could you check that?

                          PS.
                          Sorry for the late reply, I only just received the notification ... very strange.

                          ShaddersS Offline
                          ShaddersS Offline
                          Shadders
                          wrote on last edited by
                          #21

                          @kshegunov
                          Hi kshequnov,

                          Thanks - application window has nothing - simple console application.

                          I see that Wieland has provided the answer - essentially debug is set to no for standard installation.

                          Thanks and regards,

                          Shadders.

                          1 Reply Last reply
                          0
                          • ? A Former User

                            @Shadders Look at this and blame Fedora: https://forum.qt.io/topic/54820

                            ShaddersS Offline
                            ShaddersS Offline
                            Shadders
                            wrote on last edited by Shadders
                            #22

                            @Wieland
                            Hi Wieland,

                            Thank you for this - much appreciated - changed the ini file to true for debug and is now working.

                            I have a bug report with Fedora for the QtQuick application - seems to be a library dependency in error in their Fedora 23 repository.

                            https://bugzilla.redhat.com/show_bug.cgi?id=1337621

                            Fix seems to be progressing :

                            https://bodhi.fedoraproject.org/updates/FEDORA-2016-b6db59ce87

                            Only seems to affect QtQuick for the moment.

                            Thanks for the help here, much appreciated.

                            Regards,

                            Shadders.

                            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