You are not logged in.

1

Monday, January 23rd 2012, 3:46pm

qdebug and qString problem

Hi,

One problem on qdebug...



I have code like this..





Quoted


void myFunc(QString device)

{

qDebug()<<device<<"is being used";

}


When I call above function myFunc(tr("Device1"); I am expecting following output.

Quoted

Device1 is being used.

But, instead of that it prints

Quoted

"Device1" is being used. // Note " also printed.


Why " " is also appended to QString?

Junior

Professional

  • "Junior" is male

Posts: 1,623

Location: San Antonio, TX USA

Occupation: Senior Secure Systems Engineer

  • Send private message

2

Wednesday, January 25th 2012, 7:34pm

Because QString class is providing this on output not qDebug.

If you do:

qDebug() << str << "is a device."; // output: "device 1" is a device.
qDebug() << qPrintable( str ) << "is a device."; // output: device 1 is a device. (no quotes)
qDebug() << str+" is a device."; // output: "device 1 is a device."