qt-interest@trolltech.com
[Top] [All Lists]

Re: how to print QString contents - QT4

Subject: Re: how to print QString contents - QT4
From: Iulian M
Date: Fri, 31 Aug 2007 16:13:33 +0300
On Friday 31 August 2007, Brant Sears wrote:
> Or you can use the qPrintable macro:
> qDebug("%s", qPrintable(myQString));
>
> On Aug 31, 2007, at 7:48 AM, Till Oliver Knoll
>
> <oliver.knoll@xxxxxxxxxxx> wrote:
> > Vahe Avedissian schrieb:
> >> Hi,
> >> I seem to be having problems printing the data contents of QString
> >> objects.
> >> I've tried the qDebug, and printf using the dat, toAscii, to
> >> unicode, etc... methods.
> >> It compiles, but at runtime I either see the first character only,
> >> or get a crash with
> >> "Illegal instruction" message.
> >> This seemed to work with QT3.x and I cannot find any documentation
> >> or examples of
> >> how to do this correctly.
> >> What am I missing?
> >
> > The last method call to data():
> >
> >  qDebug ("The string is: %s", theQString.toLatin1().data());
> >
> > Note that toLatin1(), toAscii() etc. return a QCString only - from
> > this you still need to pass along the actual char * to qDebug, with
> > the data() method.
> >
> > Cheers, Oliver

Or you can use the friendly sintax described here: 

http://doc.trolltech.com/4.3/qtglobal.html#qDebug


qDebug() << myString << myOtherObject ; 

this may also help:

http://doc.trolltech.com/4.3/debug.html#providing-support-for-the-qdebug-stream-operator


-- 
Best Regards,
Iulian Margarintescu
http://www.erata.net
eti@xxxxxxxxx
(spamassassin & pf & spamd all said it's OK to make it public ;-) )
Key ID: 0x03176E5CEDEFF7AB
I prefer plain text email
<Prev in Thread] Current Thread [Next in Thread>