[QGIS-Developer] Replacing QLiteralString() and QLatin1String() by qt 6.4 u""_s and ""_L1 ?

Stefanos Natsis uclaros at gmail.com
Tue Dec 23 01:48:03 PST 2025


We are officially QT6 only since https://github.com/qgis/QGIS/pull/64365

Best
Stefanos


On Tue, Dec 23, 2025, 11:43 AM David Koňařík via QGIS-Developer <
qgis-developer at lists.osgeo.org> wrote:

> 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
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20251223/b9eddd94/attachment-0001.htm>


More information about the QGIS-Developer mailing list