#include#include int main() { QVector myArray; myArray.append(1); myArray.append(2); myArray.append(3); for(int i=0; i
Output:1 2 3
In the above example, we create an empty QVector called myArray. We then add integers 1, 2 and 3 to the end of the array using the append() function. Finally, we iterate through the array and print out its elements.
Example 2: Adding strings to a QVector using append()#include#include int main() { QVector myArray; myArray.append("apple"); myArray.append("banana"); myArray.append("orange"); for(int i=0; i
Output:apple banana orangeIn the above example, we create an empty QVector called myArray of string data type. We then add strings "apple", "banana" and "orange" to the end of the array using the append() function. Finally, we iterate through the array and print out its elements. Package library: Qt.