Results 1 to 7 of 7

Thread: Call script shell with Qt

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 140 Times in 132 Posts

    Default Re: Call script shell with Qt

    I think this:
    Qt Code:
    1. matlab -nojvm -nosplash -r MyCommand
    To copy to clipboard, switch view to plain text mode 
    should look:
    Qt Code:
    1. arguments << "-nojvm" << "-nosplash" << "-nodisplay" << "-r" << "addmatrix";
    2. exec->start("matlab", arguments);
    To copy to clipboard, switch view to plain text mode 

    I manually launch shell and manually the start matlab in bash mode.
    after start my Qt program and redirect the standartd input on the standard input of the shell as if the program wrote in shell to the place mine....CAN I DO THIS ???
    As I understand, you want to pass the input from you Qt app to the matlab?
    I would try starting matlab with a QProcess, and then writing and reading it's input/output, like sample code in assistant:
    Qt Code:
    1. QProcess gzip;
    2. gzip.start("gzip", QStringList() << "-c");
    3. if (!gzip.waitForStarted())
    4. return false;
    5.  
    6. gzip.write("Qt rocks!");
    7. gzip.closeWriteChannel();
    8.  
    9. if (!gzip.waitForFinished())
    10. return false;
    11.  
    12. QByteArray result = gzip.readAll();
    To copy to clipboard, switch view to plain text mode 
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  2. #2
    Join Date
    Feb 2009
    Posts
    32
    Qt products
    Qt4
    Platforms
    MacOS X
    Thanks
    3

    Default Re: Call script shell with Qt

    thanks for help ... it work... the right code is:

    Qt Code:
    1. QStringList argo, list;
    2. QProcess *exec;
    3. exec =new QProcess(this);
    4. argo <<"/Applications/MATLAB_R2008a/bin/matlab"<<"-nojvm -nosplash -nodisplay -r 'addmatrix(2,7)'";
    5. list <<"PATH=/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/X11R6/bin";
    6. exec->setEnvironment(list);
    7.  
    8. exec->start("/bin/bash", argo);
    To copy to clipboard, switch view to plain text mode 

    if there are a different mode more easy please write

Similar Threads

  1. How to use shell script files ?
    By npc in forum Newbie
    Replies: 3
    Last Post: 15th February 2007, 08:26

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
  •  
Qt is a trademark of The Qt Company.