Split QStringList in Chucks
Hi,
Is there a function in QT to split a QStringList into sections/chunks? For example, I have a QStringList with 100 items. I what to split it into 3. So for example I could get a <QVector QStringLists> with 3 sections: 1 with 33 items, 2 with 33 items, and 3 with 34 items.
I can write a function for that but I was wondering if it's already there. Something like array_split
Thanks,
Re: Split QStringList in Chucks
Hi, std::list has a splice() method, but it looks like QStringList doesn't. So maybe try std::copy or std::copy_n?
Ginsengelf
Re: Split QStringList in Chucks
QStringList inherits from QList< QString>, and this template class has a QList::mid() method that returns a chunk of the QList.
The chunk is a copy, so the original list is unchanged.