using QStringList, append to and output and join
#include <QStringList>
#include <QDebug>
int main() {
QString winter = "A, B, C";
QString spring = "D, E, F";
QString summer = "G, H, I";
QString fall = "X, Y, Z";
QStringList list;
list << winter;
list += spring;
list.append(summer);
list << fall;
qDebug() << "The Spring months are: " << list[1] ;
QString allmonths = list.join(", ");
qDebug() << allmonths;
return 0;
}
Related examples in the same category