[QGIS-Developer] Replacing QLiteralString() and QLatin1String() by qt 6.4 u""_s and ""_L1 ?
Even Rouault
even.rouault at spatialys.com
Sun Dec 21 10:50:30 PST 2025
Hi,
I personally find that QLiteralString() and QLatin1String() add
significant visual noise when reading QGIS source code. Qt 6.4 adds a
Qt::Literals::StringLiterals namespace
(https://doc.qt.io/qt-6/qt-literals-stringliterals.html) with operator""
_s(...) and operator""_operator ""_L1(...)
So code like
wallProperties.insert( QStringLiteral( "geometryModifier" ),
WALL_EXPRESSION );
wallProperties.insert( QStringLiteral( "symbolType" ),
QStringLiteral( "Fill" ) );
if ( renderer->type() == QLatin1String( "25dRenderer" ) ) { ... }
can be simplified as
wallProperties.insert( u"geometryModifier"_s, WALL_EXPRESSION );
wallProperties.insert( u"symbolType"_s, u"Fill"_s );
if ( renderer->type() == "25dRenderer"_L1 ) { ... }
For the replacement of QStringLiteral() by ""_s is is a bit unfortunate
though that we have to put the 'u' prefix to indicate this is a Unicode
string, but u""_s is still shorter than QStringLiteral( "" )
Thoughts on doing a mass replacement to those new ways?
Even
--
http://www.spatialys.com
My software is free, but my time generally not.
More information about the QGIS-Developer
mailing list