Results 1 to 9 of 9

Thread: to execute a .m file in qt on ubuntu OS

  1. #1
    Join Date
    Jun 2015
    Posts
    4
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default 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
    Last edited by CRL; 3rd June 2015 at 11:33.

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: to execute a .m file in qt on ubuntu OS

    Use QProcess .

  3. The following user says thank you to stampede for this useful post:

    CRL (3rd June 2015)

  4. #3
    Join Date
    Jun 2015
    Posts
    4
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: to execute a .m file in qt on ubuntu OS

    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
    Last edited by CRL; 3rd June 2015 at 11:35.

  5. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: to execute a .m file in qt on ubuntu OS

    Qt Code:
    1. QProcess* p = new QProcess( this );
    2. p->start( QString( "/usr/bin/octave"),
    3. QStringList() << QString("-r /home/evr/Downloads/flag.m"));
    To copy to clipboard, switch view to plain text mode 
    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 ?

  6. #5
    Join Date
    Jun 2015
    Posts
    4
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: to execute a .m file in qt on ubuntu OS

    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

  7. #6
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: to execute a .m file in qt on ubuntu OS

    Ok, this is not that hard, just append each argument to the string list one by one and everything should work ok.

  8. The following user says thank you to stampede for this useful post:

    CRL (4th June 2015)

  9. #7
    Join Date
    Jun 2015
    Posts
    4
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: to execute a .m file in qt on ubuntu OS

    Can you please tell me how to do it ??

  10. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: to execute a .m file in qt on ubuntu OS

    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,
    _

  11. #9
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: to execute a .m file in qt on ubuntu OS

    To be clear, the "-r" and the file name are two separate arguments.

Similar Threads

  1. Unable to make deb file of Qt 5.4 app in Ubuntu 14.04
    By manojpatidar in forum Installation and Deployment
    Replies: 10
    Last Post: 25th February 2015, 12:38
  2. How to execute my .css file in Qt?
    By harish in forum Qt Programming
    Replies: 5
    Last Post: 2nd December 2011, 11:12
  3. Execute a .sql file with more than one query
    By ShadowBelmolve in forum Newbie
    Replies: 6
    Last Post: 19th August 2010, 16:48
  4. cannot execute binary file
    By mgturner in forum Installation and Deployment
    Replies: 1
    Last Post: 16th March 2009, 17:04
  5. How to execute an exe file from Qt application
    By maveric in forum Qt Programming
    Replies: 1
    Last Post: 24th May 2008, 10:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.