qDebug() has stopped working - seriously
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:
- simple qDebug() code is working, I get expected output
- I edit it to experiment with .noquote and also with qtextstream
- 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.
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.
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.
Nothing or empty ?
You should add a minimal amount of text before your send your
xvariable to the debug output. You might be getting an empty reply for some reason.
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().
Which version of Qt Creator ?
By the way 4.2.2 is out.
Have you tried QString instead of standard string?
Then you should update to 4.2.2
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;