QTime::currentTime().toString() + add. text
Hi,
i am using multi-line QTextEdit as logging-window
-> all user inputs should be logged and displayed in this scrollable box.
Basicly that works as supposed in my testing-application.
Each time i need to add a new text i am using something like that
Code:
myQTextEdit->append("the new inputline which should be added to the log");
Today i had the idea to add a timestamp for each new entry.
I guess basicly i need QTime so i tried that:
Code:
myQTextEdit
->append
(QTime::currentTime().
toString());
Well that gives a new line with a timestamp...nice but not as need it.
I need a way to add a single line with the generated TimestampString and my custom defined string like in the first code-block.
Question 1:
Should i concat those strings somehow ?
Question 2:
Is the basic idea regarding my Timeconversion to String a good idea, or should i try it somehow diffrent ?
Best regards in advance
ape
Re: QTime::currentTime().toString() + add. text
What about:
Code:
myQTextEdit->append(text);
Re: QTime::currentTime().toString() + add. text
Hi Marcel,
yeah with some small cosmetic change exactly what i needed.
guess i lack some basic c++ knowledge.
but basicly the idea with currentTime().toString was ok, right ?
Or is there any other method to get a timestamp as String which you would prefer ?
Thank you very much for the fast & helpful response.
Re: QTime::currentTime().toString() + add. text
You can also format the time. The format parameter can be passed to toString. Take a look at available format strings: http://doc.trolltech.com/4.3/qtime.html#toString
Re: QTime::currentTime().toString() + add. text
Hi Marcel,
I guess you misunderstood my "with some cosmetc changes"-part.
i already did those small changes :D
But thanks again for the link and the offered help.
Best regards
ape