I am converting time_t to human readable format. For this purpose I am using asctime()
function. However it is also mentioned in c++ references.
The string is followed by a new-line character ('\n') and terminated with a null-character.
I know that I can delete '\n' character if I use char pointer. Such as;
char * str;
str(strlen(str)-1) = '\0'; // repleacing new-line char to null-char
However how can I delete new-line characther in QString? Here is my example;
time_t rawtime;
struct tm * timeinfo;
QString strList;
rawtime = 1430687052;
timeinfo = localtime (&rawtime);
strList += asctime(timeinfo);
EDIT:
I am creating report file, so that I have lots of '\n' char in my QString
, thats why replacing all '\n' char to null pointer is not good idea.
I would use QString::trimmed()
function to remove all trailing and leading whitespace characters, such as '\t', '\n', '\v', '\f', '\r', and ' '. I.e.:
strList = strList.trimmed();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With