QVectornumbers{1, 2, 3, 4, 5}; numbers.replace(2, 10); // replaces element at index 2 with value of 10 // numbers is now {1, 2, 10, 4, 5}
QVectorIn both examples, the QVector library was used.fruits{"apple", "banana", "cherry", "date"}; QVector newFruits{"pear", "grape"}; fruits.replace(1, 2, newFruits); // replaces elements at index 1 and 2 with newFruits // fruits is now {"apple", "pear", "grape", "date"}