[Interest] Efficient QString construction
Julius Bullinger
Julius.Bullinger at asctec.de
Tue Dec 15 11:02:09 CET 2015
Hello,
What is the currently recommended way to concatenate several QStrings and/or string literals? Take this code as an example:
QImage img;
QString getProjectDir();
// ...
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
2. QLatin1String
3. QStringBuilder
4. Simple string literals
Since this may have changed over time, what do current best practices say?
Best regards,
Julius
[1]: http://blog.qt.io/blog/2014/06/13/qt-weekly-13-qstringliteral/
[1] and [2]: http://woboq.com/blog/qstringliteral.html
[3:] https://wiki.qt.io/Using_QString_Effectively and
http://blog.qt.io/blog/2011/06/13/string-concatenation-with-qstringbuilder/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20151215/2db7b33a/attachment.html>
More information about the Interest
mailing list