How to Display recent Logs and can be filter according to the checkboxes?
-

Hi, I want to display the recent 10 logs in the box shown in the image, and I can filter it with checkboxes.
I have no Idea of any API. And which widgets would be best to display log in it?
No code bcz I am just getting started.@Aviral-0 What logs do you mean? From where do they come?
Logs are simple text, so you can use https://doc.qt.io/qt-6/qtextbrowser.html for example.
But if you also want to filter the logs you should go for https://doc.qt.io/qt-5/model-view-programming.html -
@Aviral-0 What logs do you mean? From where do they come?
Logs are simple text, so you can use https://doc.qt.io/qt-6/qtextbrowser.html for example.
But if you also want to filter the logs you should go for https://doc.qt.io/qt-5/model-view-programming.html -
@jsulm Hi, Thankyou for replying. If you can find any prebuild code for this, then please share! Thanks a lot!
-
@jsulm I think I need to build QProcess to show tail command output of a log file on QTextEdit Window.
Can you give me some refernce plz@Aviral-0 I don't know what you mean. If you want to read data at the end of a file why do you need to start a process for that at all?! Why don't you simply use QFile, seek to a position from where you want to read and then read?
If you want to use tail command with QProcess then please try first by yourself and ask if it does not work. There are many examples how to use QProcess. You will need to read stdout of the process to get the output from that process (https://doc.qt.io/qt-6/qprocess.html#finished + https://doc.qt.io/qt-6/qprocess.html#readAllStandardOutput). -
@Aviral-0 I don't know what you mean. If you want to read data at the end of a file why do you need to start a process for that at all?! Why don't you simply use QFile, seek to a position from where you want to read and then read?
If you want to use tail command with QProcess then please try first by yourself and ask if it does not work. There are many examples how to use QProcess. You will need to read stdout of the process to get the output from that process (https://doc.qt.io/qt-6/qprocess.html#finished + https://doc.qt.io/qt-6/qprocess.html#readAllStandardOutput).@jsulm Okay, Let me tell you what I really want to create.
I want to create a Log display window which updates logs in real time and user be able to select or copy the displayed logs from that window.
Simple example is like in the below image

As you can see the logs shown in below window.
I am still confused if these logs should be read via any file or any function is there which directly displays these logs to any widgets.
Please Help! -
@jsulm Okay, Let me tell you what I really want to create.
I want to create a Log display window which updates logs in real time and user be able to select or copy the displayed logs from that window.
Simple example is like in the below image

As you can see the logs shown in below window.
I am still confused if these logs should be read via any file or any function is there which directly displays these logs to any widgets.
Please Help!@Aviral-0 said in How to Display recent Logs and can be filter according to the checkboxes?:
I am still confused if these logs should be read via any file or any function is there which directly displays these logs to any widgets
As far as I can see you did NOT explain from where these logs are comming. I already asked you what logs those are, but you did not answer this question. So, how should I know what you should use if you refuse to answer that simple question?
-
@Aviral-0 said in How to Display recent Logs and can be filter according to the checkboxes?:
I am still confused if these logs should be read via any file or any function is there which directly displays these logs to any widgets
As far as I can see you did NOT explain from where these logs are comming. I already asked you what logs those are, but you did not answer this question. So, how should I know what you should use if you refuse to answer that simple question?
-
@jsulm These logs are the updates of ongoing process in application. It will be already available for me I guess. In a form of file i think
@Aviral-0 said in How to Display recent Logs and can be filter according to the checkboxes?:
In a form of file i think
You think?!
Before you continue you should find out how these logs are generated. If you think it is a file: where is it located and what is its name? If you don't know that how do you want to read the logs?!
Programming should not be based on guessing... -
@Aviral-0 said in How to Display recent Logs and can be filter according to the checkboxes?:
In a form of file i think
You think?!
Before you continue you should find out how these logs are generated. If you think it is a file: where is it located and what is its name? If you don't know that how do you want to read the logs?!
Programming should not be based on guessing... -
@Aviral-0 You can open the file, seek to file end and then connect a slot to https://doc.qt.io/qt-6/qfilesystemwatcher.html#fileChanged signal. In the slot you simply read to the end of the file and add the data you read to your log widget.
-
@Aviral-0 You can open the file, seek to file end and then connect a slot to https://doc.qt.io/qt-6/qfilesystemwatcher.html#fileChanged signal. In the slot you simply read to the end of the file and add the data you read to your log widget.
-
J JonB referenced this topic on