You are not logged in.

Dear visitor, welcome to If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.


Monday, April 9th 2012, 7:55am

how to use QProcess to show tail command output of a log file on QTextEdit Window?

Hi all,

I am new to Qt and C++.I need to show the contents of a log file using tail command on QTextEdit window.For this i am using QProcess,please let me know how to use QProcess to show tail command output of a log file on QTextEdit Window or is there any other way apart from using QProcess? The .cpp and .h code for the same is given below:-


logFile::logFile(QWidget *parent):QMainWindow(parent),ui(new Ui::logFile)



void logFile::on_findButton_clicked()
QString searchString=ui->lineEdit->text();

void logFile::loadTextFile()
QFile file("/var/log/system.log");|QIODevice::Text);

QTextStream in(&file);
//QString line=in.readAll();

QString cmd("tail");
QProcess* process=new QProcess(this);
process->waitForReadyRead() or waitForFinished;
QString tmp=process->readAll();



QTextCursor cursor->logTextEdit->textCursor();
cursor.movePosition(QTextCursor:: Start,QTextCursor::MoveAnchor,1);


class logFile:public QMainWindow
logFile(QWidget *parent =0);

public slots:

void loadTextFile();

private slots:
void on_findButton_clicked();

Here the problem is that i get tailed output but only of the previous command i.e only once the application is closed and reopened ,i can see the output.But i want to see the output then and there.Please help.I don't know where i am going wrong!


Wednesday, April 11th 2012, 7:24pm

search this forum for qprocess. I'm sure all questions have been answered.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.