How to Split a QString by White Spaces

You need to use a QRegExp to achieve this. “\s” means any white space character and “+” means any number of that pattern. So you can use the following line to find any number of consecutive white spaces and split you string:

line.split(QRegExp("\s+"))


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.