You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

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,622

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."