Important: Please read the Qt Code of Conduct -


  • Hi
    I have a question in qt c++.
    I want to assign each item of stringlist to another stringlists
    stringlist_1 =("k#k1#k2" , "s#s1#s2" , "b#b1#b2")
    I want to make them like this :
    stringlist_2 = ("k","k","k2")
    stringlist_3 = ("s","s1","s2")

    how can I make that?
    I tray to use this code

    for (int i=0 ; i<2 ; i++)
        QStringList d = stringlist_1.value(i).split("#");
        qDebug()<< d ; 

    I use for loop becuase my list it is very big, but
    the problem , it is storing all strings of primary list in same stringlist (d).
    how can I let for loop change the stringlist which assigned to it in each loop?
    or there is another method can I make that?

  • What about storing the stringList in another container like list?

    #include QCoreApplication
    #include QStringList
    #include QDebug
    int main(int argc, char *argv[]){
        QStringList a{"k#k1#k2" , "s#s1#s2" , "b#b1#b2"};
        QList<QStringList> list;
        foreach (const QString &s, a) {
        qDebug() << list;

Log in to reply