View Full Version : to execute a .m file in qt on ubuntu OS
hi !
i am a beginner in Qt
i am using qt in ubuntu
i want to run a .m file in octave using qt such that when a push button is clicked the .m file is executed and the output .dat file is generated
my octave location is /usr/bin/octave
.m file location is /home/evr/Downloads/flag.m
i want the .m file to be executed without any window showing up and it must directly generate the output file.
Please help me.
Thanks in advance :)
stampede
3rd June 2015, 10:51
Use QProcess (http://doc.qt.io/qt-5/qprocess.html#details) .
I've tried it.
can you please send me an example as in how to use that on this purpose.
here is what i have tried:
void MainWindow:: on_pushButton_clicked()
{
QProcess* p = new QProcess( this );
p->start( QString( "/usr/bin/octave"),
QStringList() << QString("-r /home/evr/Downloads/flag.m"));
}
Thank you :)
stampede
3rd June 2015, 12:05
QProcess* p = new QProcess( this );
p->start( QString( "/usr/bin/octave"),
QStringList() << QString("-r /home/evr/Downloads/flag.m"));
Do you have any idea what above code is doing ? If yes then please explain the last line of code.
Of course, you can just copy & paste some code from here and there and pray that it will finally work, but you will be back here asking for help with every single issue.
I could give you the solution, but I think it's better for you to solve it for yourself.
So again - what is the last line of code doing ?
when i searched online
it showed some commands like -r is to run the file
-no desktop to not show up the window
-window to show the window etc.,
so i tried that out here.
Pardon me if i am wrong.
As far as i know the last code is running the .m file flag in the specified location.
I started using Qt since just 4 days :(
stampede
4th June 2015, 08:35
Ok, this is not that hard, just append each argument to the string list one by one and everything should work ok.
Can you please tell me how to do it ??
anda_skoa
4th June 2015, 13:35
You have a QStringList, you add arguments to it like you already do.
Just each argument separately instead of all arguments in one string.
Cheers,
_
ChrisW67
6th June 2015, 12:19
To be clear, the "-r" and the file name are two separate arguments.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.