QLatin1String

Lars Knoll lars at trolltech.com
Mon Jul 12 10:08:34 BST 2004


On Sunday 11 July 2004 15:50, Thiago Macieira wrote:
> Lars Knoll wrote:
> >On Thursday 08 July 2004 21:35, Benjamin Meyer wrote:
> >> In the Qt4 docs I noticed QLatin1String which might be what we want
> >> to use in the future over QFL1
> >>
> >> http://doc.trolltech.com/4.0/qlatin1string.html
> >
> >I actually added it for exactly this reason ;-)
>
> Are you studying the possibility of a QUtf8String? Maybe also a
> QLocaleString. They may come in handy.

A utf8 string might still give you something, but a QLocaleString doesn't (as 
you always have to convert to a QString anyway) to do anything with it. The 
advantage of QLatin1String is that you can avoid temporary QStrings in lots 
of cases. 

One example: 
	QString foo = ...; 
	if(str == QLatin1String("foo")) { ... }
In this case you don't need to convert the char literal to a QString. For a 
locale string we would still need to do the conversion, so you don't gain 
anything.

Cheers,
Lars




More information about the kde-core-devel mailing list