Results 1 to 6 of 6

Thread: how to stop QProcess in app.

  1. #1
    Join Date
    Nov 2008
    Posts
    39
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question how to stop QProcess in app.

    Hi,

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include <QProcess>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. QProcess *myProcess = new QProcess;
    8. myProcess->start("notepad.exe");
    9. //QObject::connect(myProcess,SIGNAL(destroyed()),myProcess,SLOT());
    10. return a.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 

    here when the process->start is used the Notepad application is opening but when I close the notepad the app should also close, in QTCreator it still showing as running in the application output.
    how to close the QApplication when the QProcess or the application opened using the qprocess is closed.
    here I tried to use the signal and slot but how to close the main app ?
    Last edited by Lykurg; 5th October 2010 at 11:40. Reason: changed [qtclass] to [code]

  2. #2
    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: how to stop QProcess in app.

    Please note the difference between [QTCLASS] and [CODE]!

    You have to connect to the quit slot of the application object.

  3. #3
    Join Date
    Apr 2010
    Location
    Rostov-na-Donu, Russia
    Posts
    153
    Thanks
    2
    Thanked 26 Times in 23 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to stop QProcess in app.

    You can just remove a.exec();

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to stop QProcess in app.

    If he removes a.exec() then both his application and the child process will exit immediately.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Nov 2008
    Posts
    39
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to stop QProcess in app.

    if I remove the return a.exec() the application is opened but if I want to interact with any event then its a problem. so I want to close the application only when I require to close it so that's the reason why I am trying to use the connect statement. I want to interact and find if the notepad is closed if its closed then only the main app should be closed.

    how to connect the quit slot of the application to the qt class ?

    like if I had 2 processes and if one of it is close then the other one should also close.

  6. #6
    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: how to stop QProcess in app.

    Then you have to create a custom slot where you also close the second app. On how to do that, read about signals and slots in the documentation.

Similar Threads

  1. Replies: 0
    Last Post: 26th August 2010, 10:44
  2. How to stop QThread?
    By vespasianvs in forum Qt Programming
    Replies: 3
    Last Post: 14th March 2010, 06:42
  3. mapper stop after upgrade to 4.4.3
    By SunnySan in forum Qt Programming
    Replies: 6
    Last Post: 6th November 2008, 11:50
  4. how to stop particular key's action in QLineEdit
    By rajeshs in forum Qt Programming
    Replies: 1
    Last Post: 4th February 2008, 19:36
  5. Stop the thread
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 14th May 2007, 10:29

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.