in my code I need to remove the last space(s) of a QString that is an element of a QStringlist DataColumns.
This is what I have:
DataColumns[0] : "Time [ms] "
DataColumns[1] : "Position [m]"
DataColumns[2] : "End Velocity [m/s] "
This is what I want to have:
DataColumns[0] : "Time [ms]"
DataColumns[1] : "Position [m]"
DataColumns[2] : "End Velocity [m/s]"
In a loop over i (element of DataColumn) and j (letter of element of DataColumn) I do the following and it works:
QStringList dataColums;
QString A;
...
A= dataColums[i];
A.chop(1);
dataColums[i] = A;
But when I try to put the last 3 lines into 1 command it doesn`t work.
dataColums[i] = dataColums[i].chop(1);
Can anybody explain to my as to why that is? Thank you!
The function is declared like
that is it has the return type
void.So this statement
is invalid. It looks like
To remove white spaces from the both sides of a string you could use the member function
trimmed.