On Tuesday 15 December 2015 10:02:09 Julius Bullinger wrote: > Hello, > > What is the currently recommended way to concatenate several QStrings and/or > string literals? Take this code as an example:
Using the fast operator +. DEFINES += QT_USE_FAST_OPERATOR_PLUS > QString basename = QFileInfo(imgPath).baseName(); > > QString thumbPath = getProjectDir() + "/thumb_" + basename + ".jpg"; > > img.save(thumbPath); > > > I found several blog posts and wiki articles recommending one or multiple > of: > > > 1. QStringLiteral QStringLiteral is to be used when you want to actually use the literal as the whole string. That's not the case here. > 2. QLatin1String You should use QLatin1String whenever there's an overload that takes a QLatin1String. You'd need here it if you compiled with QT_NO_CAST_FROM_ASCII. > 3. QStringBuilder This is the fast operator+. > 4. Simple string literals This is the slowest. > Since this may have changed over time, what do current best practices say? The same as they've always said. -- Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel Open Source Technology Center _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest