[Qt-interest] QString doesn't print anything with qDebug
John McClurkin
jwm at nei.nih.gov
Wed Dec 1 14:07:01 CET 2010
Anisha Kaul wrote:
> Hello again,
>
> My XML file is filled with relevant data like this:
>
> <?xml version="1.0"?>
>
> <CONFIGINFO>
>
> <ABC>
> <portNM>3794</portNM>
> <timoutPeriod>10</timoutPeriod>
> </ABC>
>
> ....
>
> I wrote a small code to print the tag names, and no characters EXCEPT THE SPACES get shown up when I run it.
> The relevant (successfully compiled) code is presented here:
> _____________________________________________________________________________________________
> XmlFileReader :: XmlFileReader (string xmlFileName)
> {
> QFile *objQFile = new QFile ("config.xml");
> if (objQFile->open (QIODevice :: ReadOnly) == false)
> {
> cout << "\nError: Unable to open the XML file! Verify the file's existence and permissions\n\n";
> exit (0);
> }
>
> QXmlStreamReader objQXmlReader (objQFile);
>
> QXmlStreamReader :: TokenType token = objQXmlReader.readNext();
> QXmlStreamReader :: TokenType token = objQXmlReader.readNext();
>
> QString s = objQXmlReader.readElementText ();
>
> qDebug("--- %s ---",s.toAscii().data());
> qDebug("%s", qPrintable(s));
>
> QXmlStreamReader :: TokenType token2 = objQXmlReader.readNext();
>
> QString s2 = objQXmlReader.readElementText ();
> qDebug("--- %s ---",s2.toAscii().data());
> qDebug("%s", qPrintable(s2));
> }
> _____________________________________________________________________________________________
>
> Please see if someone can guide me on this.
> -Anisha
>
>
>
>
> -------------------------------------
> Hi-Tech Gears Limited, Gurgaon, India
>
>
>
The fact that spaces, but nothing else, are printed suggests that your
OS interprets those characters as non-printable. You might try writing
your debug statements to a binary file and look at that file with a
binary editor to see what's actually being sent through qDebug.
More information about the Qt-interest-old
mailing list