using QStringList, append to and output and join : QStringList « Qt « C++






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

1.Adding QStringList to QListWidget
2.A simple model that uses a QStringList as its data source
3.Complete demo for QStringList
4.Split QStringList
5.QStringList demo
6.Quick sort QStringList
7.STL-Style Iterators
8.Search in a list of fruit names first for the word Pear and then for Orange