QCustomPlot Discussion and Comments

Error building w/QT_USE_QSTRINGBUILDER (includes fix)Return to overview

(v2.0.1)

If building with QT_USE_QSTRINGBUILDER on, this code (line 6925):

       return QString(QLatin1String("%1%2%3/%4"))
            .arg(sign == -1 ? QLatin1String("-") : QLatin1String(""))
            .arg(integerPart > 0 ? QString::number(integerPart)+QLatin1String(" ") : QLatin1String(""))
            .arg(remainder)
            .arg(denominator);

Will produce a compile error:

qcustomplot/qcustomplot.cpp:6925:27: error: incompatible operand types ('QStringBuilder<typename QConcatenable<QString>::type, typename QConcatenable<QLatin1String>::type>' (aka 'QStringBuilder<QString, QLatin1String>') and 'QLatin1String')
                          .arg(integerPart > 0 ? QString::number(integerPart)+QLatin1String(" ") : QLatin1String(""))
                                               ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   ~~~~~~~~~~~~~~~~~
1 error generated.

Fixed by changing to:

        return QString(QLatin1String("%1%2%3/%4"))
            .arg(sign == -1 ? QLatin1String("-") : QLatin1String(""))
            .arg(integerPart > 0 ? (QStringLiteral("%1 ").arg(QString::number(integerPart))) : QLatin1String(""))
            .arg(remainder)
            .arg(denominator);

Thanks for reporting!

It'll be fixed in the next version (though not via QStringLiteral, because that's not backward-compatible). I'll also make sure to add an according compile test for the release script