If I have several QStringLists, for example:
QStringList str1 = {"name1", "name2", "name3"};
QStringList str2 = {"value1", "value2", "value3"};
QStringList str3 = {"add1", "add2", "add3"};
Is there any way to get list of lists (nested list) like QStringList listAll;
that will look like this:
(("name1","value1","add1"),("name2","value2","add2"),("name3","value3","add3"))
From the comment, it looks like you are trying pack the list of strings to a QVector
instead of QList
. In that case, do simply iterate through the QStringList
s and append the list of strings created from the equal indexes to the vector.
#include <QVector>
QVector<QStringList> allList;
allList.reserve(str1.size()); // reserve the memory
for(int idx{0}; idx < str1.size(); ++idx)
{
allList.append({str1[idx], str2[idx], str3[idx]});
}