[Interest] Putting a define with spaces in the .pro file?

Thiago Macieira thiago.macieira at intel.com
Fri Nov 13 23:35:46 CET 2015


On Friday 13 November 2015 22:26:40 Murphy, Sean wrote:
> Because the following code prints "Hello You" on the command line -
> including the quotes. However I was trying to get it to just print Hello
> You (with no quotes).
> 
> #include <QCoreApplication>
> #include <QString>
> #include <QDebug>
> 
> int main(int argc, char *argv[])
> {
>     QCoreApplication a(argc, argv);
>     qDebug() << QString(MY_STRING);
> 
>     return a.exec();
> }

That's because operator<< for QStrings always quotes them. You can do one of 
two ways to get rid of them:

	qDebug().noquote() << QString(MY_STRING);
or
	qDebug() << MY_STRING;

or, even better, if you care about the actual output format:

	std::cout << MY_STRING << std::endl;

qDebug() does *not* guarantee its output will remain stable over time. It's 
meant for debugging and your users should never have to see them.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list