[Qt-interest] QString doesn't print anything with qDebug

Anisha Kaul anisha.kaul at hitechroboticsystemz.com
Thu Dec 2 12:12:26 CET 2010


> Well, I think you're just making it too complicated for yourself. Why
> not a simple: qDebug() << "---" << s << "---";
> No need for a .toAscii().data() at all.
> André

André,

Thanks for that simple example (*It finally solved the issue*), I added
that in my code, and it resulted in a declaration error, so I looked up
QDebug documentation only to find out that I had not mentioned "#include
<QDebug>" in my code! :doh:

But I am surprised that no errors or warnings were shown when I used
QDebug like this: "qDebug("--- %s ---",s2.toAscii().data());"

> Use QXmlStreamReader::name() to get the name of the 
> tag when you encounter a start element.
> Sean

Thanks for the reminder, Sean.

> My guess is it's printing the whitespace characters inside each element,
> before the next element start tag is encountered. If you did more
> readNext() calls, you'd probably eventually see some non-whitespace,
> non-text elements.

> Elliot

Thanks to you too :) ".data()" shows only one character, not the whole string,
I think you were right, it was showing up the white spaces. and thanks for that 
small code :)

and both the following statements result in the same output.
"qDebug() << objQXmlReader.name().toString();"
"qDebug() << objQXmlReader.name();"

Thanks again to all of you for taking interest in my problem.
-Anisha


-------------------------------------
Hi-Tech Gears Limited, Gurgaon, India








More information about the Qt-interest-old mailing list