View Full Version : Split string
mero
19th March 2011, 18:01
How can I split QString by numbers of characters ?
Example:
I've got QString with 1000 characters and I want to split it to QStringList or QList<QString> by 200 chars per line?
schnitzel
19th March 2011, 18:26
how about using remove(0,200) and adding this to a QStringList in a loop?
Or you could insert a separator every 200 chars and then call QString::split on that.
mero
19th March 2011, 18:59
but what if QString will be 983 length ? It won't fit to 200.. That's why I need good, fast and easy way to split it...
schnitzel
19th March 2011, 19:17
dude come on...
your question was:
I've got QString with 1000 characters and I want to split it to QStringList or QList<QString> by 200 chars per line?
shouldn't be too hard to make it work for all cases but I'm not gonna write the code for you.
btw Qt Documentation for QString::remove() mentions:
If the specified position index is within the string, but position + n is beyond the end of the string, the string is truncated at the specified position.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.