inefficient QString coding practice

Dr. Juergen Pfennig info at j-pfennig.de
Sun Mar 14 09:38:19 GMT 2004


On Saturday 13 March 2004 19:35, Lars Knoll wrote:
> We actually know about this problem and already have a solution for this in
> Qt 4. It's called QLatin1String and is a simple wrapper around a const char
> *.
>
> So you can then write
>
> if(str == QLatin1String("foo")) { ... }
>
> and the code will
> a) compile with NO_CAST_ASCII and
> b) avoid the temporary QString.

That's a reasonable solution for those who want to keep NO_CAST_ASCII 
compatibility. Until Qt 4.0 one could define a local macro to this.

Jürgen




More information about the kde-core-devel mailing list