How do I read external file that returns me the output with each index values.
The index values are : 0 to 3;
I want to read the output from "testFile" with index. The bash file "testFile" executes with index values like this:
./testFile 1
output:-" This is my test1"
./testFile 2
output:-" This is my test2"
./testFile 3
output:-" This is my test3"
./testFile 1
output:-" This is my test1"
./testFile 2
output:-" This is my test2"
./testFile 3
output:-" This is my test3"
To copy to clipboard, switch view to plain text mode
void CMainView::ReadFileValue()
{
//Add the argument of the process
process->addArgument( "/bash" );
process->addArgument ("testFile");
connect(process, SIGNAL(readyReadStdout()), this, SLOT(readTestFileOut()));
if (!process->start())
{
qDebug("Error with process");
}
}
void CMainView::readTestFileOut()
{
QString str
= process
->readStdOut
();
//str prints only first line i.e." This is my test1"
//I want to achieve like below:-
lineEdit1->setText(str1); //str1 would be This is my test1
lineEdit2->setText(str2); //str2 would be This is my test2
lineEdit3->setText(str3); //str3 would be This is my test3
}
void CMainView::ReadFileValue()
{
QProcess * process;
process = new QProcess(this);
//Add the argument of the process
process->addArgument( "/bash" );
process->addArgument ("testFile");
connect(process, SIGNAL(readyReadStdout()), this, SLOT(readTestFileOut()));
if (!process->start())
{
qDebug("Error with process");
}
}
void CMainView::readTestFileOut()
{
QString str = process->readStdOut();
//str prints only first line i.e." This is my test1"
//I want to achieve like below:-
lineEdit1->setText(str1); //str1 would be This is my test1
lineEdit2->setText(str2); //str2 would be This is my test2
lineEdit3->setText(str3); //str3 would be This is my test3
}
To copy to clipboard, switch view to plain text mode
Bookmarks