How to display value in textEdit "only one at a time"
-
Hello all,
I am reading interger value from a txt file and displaying it in textEdit. Program is reading the file line by line but displaying only the last values in textEdit.
Requirement is to display the first value then wait for 1 seconds then second value from file should overwrite the earlier value and again wait for 1 second and so on...Kindly suggest the solution..
Thanks in advance..
Regards,
Anuj -
Hi, and welcome @anuj-nogja,
You can use a QTimer with a timeout of 1 second to read the next line from the file and display it in the textEdit.
-
@anuj-nogja
Use a timer with 1 sec and on timeout update textedit reading from file... -
In addition to what @aha_1980 and @Tirupathi-Korla already said, if your 1-second requirement is based on assumptions about when the file is updated, you could consider using QFileSystemWatcher's fileChanged signal too.
Cheers.
-
@Paul-Colby
I don't think those are necessary. -
@Tirupathi-Korla, agreed. It's just that, depending on the use case, it can yield a better user experience, such as providing a significantly lower update latency. Just an option. As you say, not necessary.
Cheers.
-
@Paul-Colby thanks