Adding comma separated strings to an ArrayList and vice versa

前端 未结 11 1230
旧巷少年郎
旧巷少年郎 2021-01-01 05:18

How to add a comma separated string to an ArrayList? My string \"returnedItems\" could hold 1 or 20 items which I\'d like to add to my ArrayList \"selItemArrayList\".

<
11条回答
  •  轮回少年
    2021-01-01 06:08

    If the individual items aren't quoted then:

     QString str = "a,,b,c";
    
     QStringList list1 = str.split(",");
     // list1: [ "a", "", "b", "c" ]
    

    If the items are quoted I'd add "[]" characters and use a JSON parser.

提交回复
热议问题