Hi,
I'm glad you've opened this discussion. I'm personally in favour of moving from the macros to the new string literal operators, since I think that both have next to no value for a programmer reading the code, so I favour the less intrusive option.

Though as far as I know, we still support building QGIS with Qt 5, so this will have to wait until we're officially Qt 6-only.

David Koňařík

On 12/21/25 19:50, Even Rouault via QGIS-Developer wrote:
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


_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to