How to write another Thread data in txt file?
-
wrote on 19 Oct 2021, 07:23 last edited by
Hello.
I want to write data from another thread in txt file.
Text files will be named currentTime() and created periodically every minute.
So, Txt file made very well every minute using QTimer, but In Txt file, content is null.
Of course this result is correct. Because i didn't connect data from another Thread.
How to connect or send data from another thread to QTimer make the txt file every minute?
For example, another thread get data every second and QTimer make txt file every minute.
Ideally, another thread get 60 data in minute and one text file made in minute.
I want to write 60 data to txt file one cycle. -
Hello.
I want to write data from another thread in txt file.
Text files will be named currentTime() and created periodically every minute.
So, Txt file made very well every minute using QTimer, but In Txt file, content is null.
Of course this result is correct. Because i didn't connect data from another Thread.
How to connect or send data from another thread to QTimer make the txt file every minute?
For example, another thread get data every second and QTimer make txt file every minute.
Ideally, another thread get 60 data in minute and one text file made in minute.
I want to write 60 data to txt file one cycle.@duckrae Move the one minute timer to the thread. When the timer times out emit a signal in the thread passing the collected text as signal parameter. Connect this signal to a slot and write the file in that slot.
-
@duckrae Move the one minute timer to the thread. When the timer times out emit a signal in the thread passing the collected text as signal parameter. Connect this signal to a slot and write the file in that slot.
wrote on 19 Oct 2021, 08:05 last edited by@jsulm Thanks for answer. this is another question. if i start qtimer like this
QTimer *timer = new QTimer(this) timer->start(60000);
the time start not now but one minute left.
I want to start QTimer now -> one minute -> one minute
but now code one minute -> one minute -> one minute.
How can I handle it? -
@jsulm Thanks for answer. this is another question. if i start qtimer like this
QTimer *timer = new QTimer(this) timer->start(60000);
the time start not now but one minute left.
I want to start QTimer now -> one minute -> one minute
but now code one minute -> one minute -> one minute.
How can I handle it?@duckrae said in How to write another Thread data in txt file?:
How can I handle it?
Simply emit the signal:
QTimer *timer = new QTimer(this) timer->start(60000); emit myTimeoutSignal(text);
2/4