How can I capture the part of my QString
Solved
General and Desktop
-
Hi All,
I'm using qt5.5 on my computer and Linux+QT for my OS system.
I've got a string like this.TWO.M TRS-M28\n
And I just need
TWO.M TRS-M28
.
I've seen the QString document.
I don't see any function that have this ability to do it.
How can I solve this problem?
Or any advise?
Thanks in Advanced! -
Hi,
If you just want to drop the last character: QString::chop
-
-
@victor-wang
HiQString str = " lots\t of\nwhitespace\r\n ";
str = str.trimmed();
// str == "lots\t of\nwhitespace"
or
scan_info = scan_info.chop(1); -
@victor-wang
alternatively:QString s("TWO.M TRS-M28\n"); QString removeMe("\n"); if(s.endsWith(removeMe)) s.remove(s.length()-removeMe.length(), removeMe.length());
-
If you'd read the documentation of the
chop
method which also has an example, you would have seen that it modifies the string in-place.By the way, where's that
scan_info.mid(19)
coming from ?