fairly new to Qt.
I'm using QProcess to run an external shell script and redirecting the output to a textBrowser on my GUI. Code:
In mainwindow.h:
private:
QProcess *myProcess;
and mainwindow.cpp:
void MainWindow::onButtonPressed(){
myProcess = new QProcess(this);
myProcess->connect(myProcess, SIGNAL(readyRead()), this, SLOT(textAppend()));
myProcess->start("./someScript.sh", arguments);
}
void MainWindow::textAppend(){
ui->textBrowser->append(myProcess->readAll());
}
This works perfectly to run an external script. My question is how to apply the same process with the script included as a resource file.
I've tried simply replacing "./someScript.sh"
with the resource version ":/someScript.sh"
but it does not seem to work.
The resource script runs perfectly, but the console output disappears.
For this reason, there is something called "QTemporaryFile" class.
Because you need to call a file that already exists in your system - ok!
let's take this example :
using QProcess we need to run a python file from resource
and for more informations you can visit Qt Documentation - QTemporaryFile Class
Good Luck ♥