diff --git a/src/corelib/tools/qvector.cpp b/src/corelib/tools/qvector.cpp index 99e1db1cab..50c90ad746 100644 --- a/src/corelib/tools/qvector.cpp +++ b/src/corelib/tools/qvector.cpp @@ -463,6 +463,18 @@ \sa operator<<(), prepend(), insert() */ +/*! \fn void QVector::append(const QVector &value) + + \overload + + \since 5.5 + + Appends the items of the \a value vector to this vector. + + \sa operator<<(), operator+=() +*/ + + /*! \fn void QVector::prepend(const T &value) Inserts \a value at the beginning of the vector. diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 9c8d9d4cf8..c00bd07a72 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -128,6 +128,7 @@ public: T &operator[](int i); const T &operator[](int i) const; void append(const T &t); + inline void append(const QVector &l) { *this += l; } void prepend(const T &t); void insert(int i, const T &t); void insert(int i, int n, const T &t); diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index 9a79d48472..c9e8a5f657 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -575,6 +575,18 @@ void tst_QVector::append() const QCOMPARE(v.last(), SimpleValue::at(0)); } #endif + { + QVector v; + v << 1 << 2 << 3; + QVector x; + x << 4 << 5 << 6; + v.append(x); + + QVector combined; + combined << 1 << 2 << 3 << 4 << 5 << 6; + + QCOMPARE(v, combined); + } } void tst_QVector::appendInt() const