[Development] RFC: [Logging] Add quote(), noquote() stream modifiers to QDebug

Matthew Woehlke mw_triad at users.sourceforge.net
Fri Feb 28 21:18:05 CET 2014


On 2014-02-28 05:41, Koehne Kai wrote:
> While contemplating about how to best get rid of qPrintable I came up with the following proposal:
>
> https://bugreports.qt-project.org/browse/QTBUG-37146

Honestly, I'm pretty happy with the qPrintable way of doing things. (At 
least, I am pretty sure I don't want noquote to become the default.) I'd 
also be happy with escaping becoming default.

Usually when I am using QDebug, I am using it like Python's repr(), to 
print representational forms of objects, and I feel like I usually 
*want* quoted QString (if I care at all). Where I want to use a QString 
as 'raw' text, it's easy to wrap it in qPrintable (or maybe some 
new-but-similar function going forward).

I could even see doing it like qDebug() << noquote(s), where 
noquote(QString) takes a QString and returns a shallow wrapper object 
whose only purpose is to be printed differently by QDebug.

OTOH, probably most of the time I want unquoted QString, I would end up 
calling 'noquote()' immediately, and quote() almost never, so...

p.s. @Friedemann, in your example I usually *want* the file name to be 
quoted... Maybe we could let the developer change the default 
quote/escape/etc. behavior per logging level?

-- 
Matthew




More information about the Development mailing list