Compiling with QT 5.11.1 & QT_USE_QSTRINGBUILDER, i get an error with the following code block:
QString generateQuery(const QString& tableName, const QStringList& columns, int count) { QString fields = "*"; if (!columns.isEmpty()) { fields.clear(); for (const QString& field : columns) { fields += (fields.isEmpty() ? "" : ", ") + '"' + field + '"'; } } ... I just want to build a comma separated list of the items in 'columns', surrounded by quotes. But instead of giving "A", "B", "C", this gives UNIQUE (%1)"A"UNIQUE (%1)"B"UNIQUE (%1)"C" That UNIQUE (%1) is only found in another cpp file of the same DLL project, in strings ", UNIQUE (%1)" passed to QString constructors. So not only is it using the wrong string litteral, it does not read it from the string start. Passing one/both of the operands of the ternary operator as QStrings makes the problem disappear. Are there things i should be aware of when using QStringBuilder, such as 'do not put expressions on operators, because of macros that will evaluate them multiple times', or something like that? String pooling (/GF of visual studio) is not used, if that matters
_______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest