diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index f7ddb5fc8e..819086b014 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -3254,7 +3254,14 @@ QString &QString::append(QChar ch) \overload prepend() - Prepends the Latin-1 string \a str to this string. + Prepends the Latin-1 string view \a str to this string. +*/ + +/*! \fn QString &QString::prepend(QUtf8StringView str) + \since 6.5 + \overload prepend() + + Prepends the UTF-8 string view \a str to this string. */ /*! \fn QString &QString::prepend(const QChar *str, qsizetype len) diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index a6cc1cf867..573fca6481 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -701,6 +701,7 @@ public: inline QString &prepend(const QString &s) { return insert(0, s); } inline QString &prepend(QStringView v) { return prepend(v.data(), v.size()); } inline QString &prepend(QLatin1StringView s) { return insert(0, s); } + QString &prepend(QUtf8StringView s) { return insert(0, s); } inline QString &operator+=(QChar c) { return append(c); } diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index 037c3043e2..65c9e086cc 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -399,6 +399,8 @@ private slots: void prepend_qstringview_data() { prepend_data(EmptyIsNoop); } void prepend_qlatin1string() { prepend_impl(); } void prepend_qlatin1string_data() { prepend_data({EmptyIsNoop, Latin1Encoded}); } + void prepend_qutf8stringview() { prepend_impl(); } + void prepend_qutf8stringview_data() { prepend_data(EmptyIsNoop); } void prepend_qcharstar_int() { prepend_impl, QString &(QString::*)(const QChar *, qsizetype)>(); } void prepend_qcharstar_int_data() { prepend_data(EmptyIsNoop); } void prepend_qchar() { prepend_impl, QString &(QString::*)(QChar)>(); }