diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index d25b8e2082..14ed315710 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -2072,6 +2072,22 @@ QString &QString::append(QChar ch) Prepends the Latin-1 string \a str to this string. */ +/*! \fn QString &QString::prepend(const QChar *str, int len) + \since 5.5 + \overload prepend() + + Prepends \a len characters from the QChar array \a str to this string and + returns a reference to this string. +*/ + +/*! \fn QString &QString::prepend(const QStringRef &str) + \since 5.5 + \overload prepend() + + Prepends the string reference \a str to the beginning of this string and + returns a reference to this string. +*/ + /*! \fn QString &QString::prepend(const QByteArray &ba) \overload prepend() diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 06eb902161..532b294c28 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -428,7 +428,9 @@ public: QString &append(const QStringRef &s); QString &append(QLatin1String s); inline QString &prepend(QChar c) { return insert(0, c); } + inline QString &prepend(const QChar *uc, int len) { return insert(0, uc, len); } inline QString &prepend(const QString &s) { return insert(0, s); } + inline QString &prepend(const QStringRef &s) { return insert(0, s); } inline QString &prepend(QLatin1String s) { return insert(0, s); } inline QString &operator+=(QChar c) { diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 266cd667f9..d4b3ba7f15 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -375,8 +375,12 @@ private slots: void prepend_qstring() { prepend_impl(); } void prepend_qstring_data() { prepend_data(true); } + void prepend_qstringref() { prepend_impl(); } + void prepend_qstringref_data() { prepend_data(true); } void prepend_qlatin1string() { prepend_impl(); } void prepend_qlatin1string_data() { prepend_data(true); } + void prepend_qcharstar_int() { prepend_impl, QString &(QString::*)(const QChar *, int)>(); } + void prepend_qcharstar_int_data() { prepend_data(true); } void prepend_qchar() { prepend_impl, QString &(QString::*)(QChar)>(); } void prepend_qchar_data() { prepend_data(true); } void prepend_qbytearray() { prepend_impl(); }