Closed hasselmm closed 5 years ago
The documentation discourages its use because the format specifiers are not safe (on ancient compilers), but it isn't deprecated and actually the perfect fit for the intended use. QString::arg() also would have unnecessary allocations, which is exactly the reason why QString::sprintf() got deprecated in favor of QString::asprintf().
#if QT_DEPRECATED_SINCE(5, 14)
QT_DEPRECATED_X("Use vasprintf(), arg() or QTextStream instead")
QString &vsprintf(const char *format, va_list ap) Q_ATTRIBUTE_FORMAT_PRINTF(2, 0);
QT_DEPRECATED_X("Use asprintf(), arg() or QTextStream instead")
QString &sprintf(const char *format, ...) Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
#endif
static QString vasprintf(const char *format, va_list ap) Q_ATTRIBUTE_FORMAT_PRINTF(1, 0);
static QString asprintf(const char *format, ...) Q_ATTRIBUTE_FORMAT_PRINTF(1, 2);
I guess it's better than the gurrent code anyway
sprintf() causes redudant allocations and therefore got deprecated.