mc307
mc307

Reputation: 19

Split a QString at Tab Space

How can I split a QString at Tab Space? I have this:

QStringList slOut;
                QString str = slOut.at(i);
                strsplit = str.split("\\t");

I have also tried strsplit = str.split("\\t"); but it doesn't work neither...

Upvotes: 1

Views: 4432

Answers (1)

TheDarkKnight
TheDarkKnight

Reputation: 27629

You can simply add the tab in the split function, without having to use \t.

QString input("About to split   Split done"); // tab character between split and Split
QStringList splitList = input.split("   "); // a tab character between the qutoes

This produces two strings in the string list "About to Split" and "Split done".

Note that the character in between the quotes of the split function is a tab, not spaces.

Upvotes: 2

Related Questions