constructing a string using temporaries
-
i need a alike method:
QString constructWidgetTitle(const QString &sPrefix, const QString &sWidgetTitle) { return sPrefix + "_" + sWidgetTitle; }is this the correct way to do it? or i should use
QLatin1String(or what?) for constructing the"_"? -
The above is correct (unless you disabled this feature in your project file), using
return sPrefix + QLatin1String("_") + sWidgetTitle;, however, is more efficient.If you have a lot of
+s then the best solution is to#include <QStringBuilder>and use%instead of+