You are not logged in.

Dear visitor, welcome to 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.


Monday, January 23rd 2012, 3:46pm

qdebug and qString problem


One problem on qdebug...

I have code like this..


void myFunc(QString device)


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


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


Device1 is being used.

But, instead of that it prints


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

Why " " is also appended to QString?



  • "Junior" is male

Posts: 1,623

Location: San Antonio, TX USA

Occupation: Senior Secure Systems Engineer

  • Send private message


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