0

In Qt I'm writing continuously to text file, so my file size increasing but i want kept size limit so need to delete old data in text file.

I calculating file size in MB for every minute if file size is greater than 600MB I used QFile::resize(100); now file size is 100MB but data is older only , I wanted after resize data should be latest written to file.

  • Use a fixed size circular buffer and keep a pointer to the current position. As you add to the end it will overwrite. To print the file, start at the pointer and skip the first line fragment. – stark Dec 22 '22 at 12:27
  • @stark As per your suggestion it works for me. – Rajendra Aware Feb 02 '23 at 06:02

1 Answers1

0

Operating systems do not support cutting a file at the beginning. Most common solution for big log files is to close the file, rename it and create a new file.