Results 1 to 5 of 5

Thread: A question about QProcess

  1. #1
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    694
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default A question about QProcess

    Hi to all,
    I would execute many times ( let say 10 times ) the same shell-based program from my Qt-application.
    So I know that I can use QProcess to achieve my needs.

    I think to put in a loop the call to the external program passing every time a new argument.

    My doubt is this: when the external program finish, the process get destroyed?
    In brief, I have to create every time a new process or can I use always the same with different arguments?
    Thankx.
    Regards
    Franco Amato

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A question about QProcess

    Hi Franco,

    you can reuse QProcess instance but you have to wait until each external program terminates.
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: A question about QProcess

    And please, don't use a loop. The magic word is Signal&Slots: QProcess::finished().

  4. #4
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    694
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A question about QProcess

    Quote Originally Posted by Lykurg View Post
    And please, don't use a loop. The magic word is Signal&Slots: QProcess::finished().
    Hi Lykurg,
    thank you very much. So once the external process has finished I can call it again with a new argument right ( in my case a QStringList containing a list of mp3 files )? So the process is not destroyed once the external program has finished? I have to destroy it manually?

    @mcosta: I didn't get you. Why I have to wait that each external program terminates to reuse the process?
    I would reuse it once the last is finished.

    So something like this is not correct?

    QString program = "my.exe";
    QStringList argument;
    QProcess *myProcess = new QProcess(parent);

    for ( int ix = 0; ix < 10; ix++ )
    {
    argument.clear();
    argument << newargument;
    myProcess->start(my.exe, argument);
    }


    Thank you very much.
    Regards
    Last edited by franco.amato; 2nd August 2011 at 17:54.
    Franco Amato

  5. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: A question about QProcess

    Quote Originally Posted by franco.amato View Post
    So once the external process has finished I can call it again with a new argument right ( in my case a QStringList containing a list of mp3 files )?
    That's right.
    So the process is not destroyed once the external program has finished?
    Yes, your QProcess object will live on.
    I have to destroy it manually?
    QProcess inherits QObject, so the same rules as for most of the other Qt-classes apply also. Also think about creating a QProcess object as a member of your corresponding class. Then you don't have to take care about deleting.

    Lykurg

Similar Threads

  1. QProcess question
    By PH5 in forum Newbie
    Replies: 0
    Last Post: 4th February 2010, 23:43
  2. question on QProcess
    By wagmare in forum Qt Programming
    Replies: 3
    Last Post: 17th January 2009, 07:23
  3. QProcess question
    By lni in forum Qt Programming
    Replies: 3
    Last Post: 19th July 2007, 19:06
  4. Question about QProcess
    By lni in forum Qt Programming
    Replies: 5
    Last Post: 27th April 2007, 23:08
  5. QProcess Question
    By Vash5556 in forum Qt Programming
    Replies: 1
    Last Post: 26th February 2007, 16: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
  •  
Qt is a trademark of The Qt Company.