QT5 qDebug()<<QByteArray empty
i have a problem,i try get html use QNetworkAccessManager from a url.statusCode is 200,debug reply->readAll() hava data,length is 35988,but use qDebug() print it's empty,nothing,im environment windown7 x32 chinese +qt5.5 x32(mingw),copy code to linux(qt5.5 x64),it's ok,can print html content,why?please help me ,thanks.my code like this:
request.setRawHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36" );
QNetworkReply *reply = manager->get(request);
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
QByteArray res= reply->readAll();
// QString str = QString::fromUtf8(res.data(), res.size());
I'm no sure, but i think problem in using '<<' operator, since Qt 5.5 Win. Try to use qDebug(res.constData()) instead.
I have problem too with qDebug() on Qt 5.5. When i try something like:
QString str = 'Проверка'; // Russian
qDebug() << str;
in messageHandler i get msg = '\u0422\u0435\u0441\u0442' and i can't solve this problem.
But if qDebug() << 'Проверка' or qDebug(str.toLocal8Bit().data()) is all fine.
Couple of things might be going on here...
If you are running your application on the console and expecting so see output you need to make sure you have
CONFIG += consolein your pro file. This only seems to affect windows applications, which is why linux works fine and windows doesn't print anything.
Make sure you have Qt Debugging enabled. In linux for me I have to turn off Qt debugging while using plasma5 as it outputs way way too much to /var/log/messages. So I do
export QT_LOGGING_RULES="*.debug=false"This turns off the ability to see qDebug() messages in my own apps as well. SO I have to
unset QT_LOGGING_RULESto see my messages. So make sure in windows you don't have any QT_LOGGING_RULES environment variables set.
My guess would be #1. :) Mainly because that has happened to me a number of times when I forget to add the console to config.