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. qDebug() has stopped working - seriously
QtWS25 Last Chance

qDebug() has stopped working - seriously

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 3 Posters 2.7k 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.
  • cpperC Offline
    cpperC Offline
    cpper
    wrote on last edited by cpper
    #1

    I was experimenting with qDebug().noquote() and QTextStream(stdout) to print a QByteArray's content, and after undoing my code back to the initial simple qDebug() statements, which worked before, I no longer get any output at all. It's like something changed in the behavior of qDebug. I restarted qt creator, made another project, but with no help. Does this make any sense ?
    Providing code doesn't help, but what I'm trying to say is:

    1. simple qDebug() code is working, I get expected output
    2. I edit it to experiment with .noquote and also with qtextstream
    3. I un-do (ctrl z) the code back to state #1 and now don't get any output.

    The initial QByteArray didn't change, printing it with QTextStream still works fine.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      A minimal code sample would still be useful to try to reproduce your problem.

      You should also add the Qt version and platform you are running on.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • cpperC Offline
        cpperC Offline
        cpper
        wrote on last edited by
        #3

        Hi SGaist, and thanks for helping out again :)

        This is the initial code, I was trying to see what output I get from different methods.

        QByteArray x=reply->readAll();
        
            qDebug()<<x.toStdString().c_str();
            qDebug()<<QString(x);
            qDebug()<<QString::fromUtf8(x);
            qDebug()<<x;
        

        It was working fine, the first line had the nicest output because it actually displayed newlines and tabs instead of '/n' or '/x9 ' . But I didn't like the idea of converting to std::string so I tried something with qDebug().noquote(). As far as I remember, this is how the code next looked:

        QByteArray x=reply->readAll();
        
           //qDebug()<<x.toStdString().c_str();
           //qDebug()<<QString(x);
           //qDebug()<<QString::fromUtf8(x);
           qDebug().noquote()<<x;
        

        I didn't get the expected output, so I googled a bit and did something like:

        QByteArray x=reply->readAll();
        QTextStream out(stdout);
        
            //qDebug()<<x.toStdString().c_str();
            //qDebug()<<QString(x);
            //qDebug()<<QString::fromUtf8(x);
            out<<x;
        

        The output was looking nice, with actual newlines and tabs. Next I ctrl-z-ed back to the initial code, compiled, and got nothing, without changing anything in the code.

        I'm using Qt_5_8_0_MSVC2015_64bit on Win 7.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Nothing or empty ?

          You should add a minimal amount of text before your send your x variable to the debug output. You might be getting an empty reply for some reason.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • cpperC Offline
            cpperC Offline
            cpper
            wrote on last edited by cpper
            #5

            Doing qDebug()<<"something"<<x; doesn't print anything. qDebug()<<"anything"; qDebug()<<"something"<<x; only prints "anything".
            The network reply is not empty, I can print it successfully with QTextStream, or write it to a file with QFile::write().

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Which version of Qt Creator ?

              By the way 4.2.2 is out.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              cpperC 1 Reply Last reply
              0
              • AsimovA Offline
                AsimovA Offline
                Asimov
                wrote on last edited by
                #7

                Have you tried QString instead of standard string?

                1 Reply Last reply
                0
                • SGaistS SGaist

                  Which version of Qt Creator ?

                  By the way 4.2.2 is out.

                  cpperC Offline
                  cpperC Offline
                  cpper
                  wrote on last edited by
                  #8

                  @SGaist It's Qt Creator 4.2.1
                  @Asimov I'm not sure what you mean.

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Then you should update to 4.2.2

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    1
                    • AsimovA Offline
                      AsimovA Offline
                      Asimov
                      wrote on last edited by
                      #10

                      @cpper
                      Sorry it took so long to get back, been busy.
                      I was thinking something like this.
                      Of course I didn't have your function to try this with, but thought this might work.
                      I am converting a QByteArray to a QString and then displaying it.

                      It probably won't help, but might be worth a try (I might not be understanding everything in your code though).

                      QByteArray qString("A Qbyte String");
                      QString myString(qString);
                      qDebug()<<"Your string is" << myString;
                      
                      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