Ways to use MPI executable in Qt? - qt

I have developed an application which comprises of a frontend Qt-GUI and a solver EXE. As these two are independent module, I could successfully launch EXE in Qt-GUI by using a QProcess like below:
QProcess *myProcess = new QProcess;
myProcess->start(exeFilePath, args);
Where
exeFilePath = "EXE"
args = "input1 -option1 name1 -option2 name2"
From QProcess's signals, I could successfully read from output channels and update the progress in a Qt-GUI's QGLWidget.
Things have changed by time. EXE is now MPI-EXE, an MPI based executable and I need to use it through Qt-GUI in a practical way.
I tried the above QProcess exercise for MPI-EXE with the following change:
exeFilePath = "mpirun -np 4 MPI-EXE"
When doing this, myProcess could not be started and when error was printed, it gave UnknownError. As I understand, QProcess itself runs in a separate thread and from this I have to launch a 4-process MPI-EXE which makes this problematic.
I need help in :
How can I launch MPI-EXE without Qt-GUI freezing ?
How can I monitor progress of MPI-EXE as I have to plot the progress in QGLWidget ?
I will really appreciate any comments on my questions.
Please help. Thanks.

Related

Detect if QTest is running

I have a class which has multiple unit-tests. I run them every time in a main function using QTest::qExec(new Test_MyClass) call. I'd like to see some qDebug() output when operating with MyClass, but not while running tests. Are there any Qt #defines to help me with that?

Launching of process on mac using Qt

i am working on sample applications using QT on Mac and i found out problem with one of its API. I want to run process so i am using following function
QProcess::startDetached();
And i am passing program(location of exe )and argument list as parameter now problem is that if the application is allready running then the this will create another process and runs it where as when i cross cheked with Windows its behavior is different in the sense that it does not start application which is allready running. can anyone help me how to fix the issue??
I think, it depends on the application properties. On window you can open multiple Doc files but cannot open Window Media player in two different (new) window.
So, First try opening a new application while its running. If its success, then it should work with QProcess .

How to call an app that expects stdin input from QtGui?

I'm using Ubuntu and Qt Creator 4
I have a .cpp program in the executable form (say abc.out) that I wish to run when I press a button. It contains a number of cin and cout, so I want it to run on a "terminal" (on Ubuntu) so that I am able to input and output values to it. How can I do that?
I've tried system() and
also,
QProcess p1;
p1.start(./abc.out);
Using QProcess, my executable runs but stops at the first cout. It runs on the application output screen in Qt Creator and not on terminal.
For example:
I see on application output:
enter name:
When I type the value and press enter here, it doesn't accept the value, but moves to the next line and allows me to type further.
I want to run this abc.out file on the terminal. Any ideas would be really helpful.
Do you mean Qt Creator 2.4? In any case, on the Projects tab, you should find the Run settings section and from there you can find a "Run in terminal" checkbox. You could also use a Custom Executable option and type there: gnome-terminal --command ./abc.out The exact details can vary a bit as I'm using Qt Creator 2.5.
This should work when launching from Qt Creator, but when you use your app outside the IDE, you need to launch it from terminal and not by double clicking the executable. To fix this, I can think of two ways:
Launch a terminal window from QtGui (something like QProcess::execute("gnome-terminal --command ./abc.out"); ), though the problem is different systems have different terminal names.
Provide a Qt input/text box yourself as part of your GUI which then forwards the user input to the executable (something like myqprocess.write(input_asked_from_user_by_QtGui); ). Here you probably need to know what information to ask the user beforehand. If you want to display the cout output of the started process, you can use the read method and friends of the QProcess.
From your question I assume that you are writing an application that launches other applications using QProcess. Thats fine, but if your subprocess is waiting for data from the standard input it will wait forever since you did not provide any data. The stdin of your parent application cannot be automatically guided to the subprocess. Imagine you are starting two processes from your main app. To which child process should the input go?
If you want to communicate with child processes, you must use the QIODevice methods of QProcess and send/read data from/to that application.
The only sensible solution is to launch the target application in a terminal. Whether your own code provides the terminal window or you reuse an existing terminal application is up to you.

After executing a shell script, the QT GUI is blocked

I have a GUI implemented with QT. The GUI has many buttons and one of them executes a shell script:
system("/bin/sh executeScene.sh");
The script is executed properly but, the GUI is blocked until I close the script that was previously called. Is there a way to execute my shell script without blocking the GUI?
The GUI has another button to stop the shell script but, as the GUI is blocked, I cannot stop the script.
Use QProcess to run the process asynchronously.
hye, i used this for one of my GUI applications...
void MainWindow::on_pushButton_clicked()
{
QProcess process;
process.startDetached("/bin/sh", QStringList()<< "/path/to/your/shell.sh");
}

how to find the running process and kill the process in QT?

i am developing a very simple application for nokia mobile.my task is to find what are all the process currently running ? after that i have to kill(exit that application i.e camera or musicplayer) that process! i have tried to find some simple method in Qprocess but there is no function to listout the current process. is there any possible way in NokiaQT or i have to use symbianC++????
Qt does not provide an API to do this. You will need to use the appropriate OS API instead. I'm not familiar with Symbian, so I can't tell you what that might be.

Resources