Results 1 to 20 of 21

Thread: QProcess disconnect trouble

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2008
    Posts
    19
    Thanks
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QProcess disconnect trouble

    Thanks for the tip, I will try that out instead of using process->kill().

    That still does not, however, address the issue with the signals not being disconnected.

    Any ideas?

  2. #2
    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: QProcess disconnect trouble

    You can't write formal parameters in SIGNAL macro neither in connect nor in dosconnect. See program output in 'Output' window in Studio. Wrong calling of connect/disconnect writes there a message

  3. #3
    Join Date
    Oct 2008
    Posts
    19
    Thanks
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QProcess disconnect trouble

    Quote Originally Posted by borisbn View Post
    You can't write formal parameters in SIGNAL macro neither in connect nor in dosconnect. See program output in 'Output' window in Studio. Wrong calling of connect/disconnect writes there a message
    I haven't seen any problems in the output. I'm also not sure what you mean by formal parameters. Do you mean defining the variable name in the function like:
    Qt Code:
    1. SIGNAL(error(QProcess::ProcessError error))
    To copy to clipboard, switch view to plain text mode 
    I know that this will not work and the signals I have defined do not define the value "error" I know that the SIGNALS are connected as they will enter the slot. I corrected this error from my first post.

    Either way, calling process->disconnect() should disconnect all the sender object and all signals from all receiver objects and slots.

    I've even tried calling
    Qt Code:
    1. process->blockSignals(true);
    2. process->kill();
    3. process->blockSignals(false);
    To copy to clipboard, switch view to plain text mode 
    and my slots still get entered.

    Any one have any other ideas as to why my signals are not getting disconnected?
    Last edited by wally; 5th April 2010 at 16:48.

  4. #4
    Join Date
    Oct 2008
    Posts
    19
    Thanks
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QProcess disconnect trouble

    I think QtCentre's moving to a new host may have ruined the code tags in my initial post. So that everyone is clear:
    I've connected my signals to my process in the Dialog's constructor like this (and I have verified that they are connected):
    Qt Code:
    1. process = new QProcess();
    2. connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(handleProcessError(QProcess::ProcessError)));
    3. connect(process, SIGNAL(finished(int, QProcess::ExitStatus )), this, SLOT(handleProcessFinish(int, QProcess::ExitStatus)));
    To copy to clipboard, switch view to plain text mode 

    When pushing the stop button, I want to kill the process with QProcess::kill(). When the process is killed, naturally, the handleProcessError slot gets called and I do not want this. I wanted to disable this by using:
    Qt Code:
    1. disconnect(process, SIGNAL(error(QProcess::ProcessError)), 0, 0);
    2. disconnect(process, SIGNAL(finished(int exitCode, QProcess::ExitStatus)), 0,0);
    3. process->kill();
    To copy to clipboard, switch view to plain text mode 

    I've also tried calling:
    Qt Code:
    1. process->disconnect();
    2. process->kill();
    To copy to clipboard, switch view to plain text mode 
    in an attempt to blindly disconnect everything.

    the slots, handleProcessError and handleProcessFinish are still being called.
    Last edited by wally; 5th April 2010 at 16:47.

Similar Threads

  1. Disconnect slot when another is being connected
    By holst in forum Qt Programming
    Replies: 4
    Last Post: 8th September 2009, 09:49
  2. auto-disconnect in ~QGraphicsItem?
    By Lykurg in forum Qt Programming
    Replies: 2
    Last Post: 22nd July 2008, 08:14
  3. QTcpSocket not recognizing disconnect
    By jimroos in forum Qt Programming
    Replies: 3
    Last Post: 6th September 2007, 15:31
  4. How to make QHttp detect a disconnect?
    By gfunk in forum Qt Programming
    Replies: 1
    Last Post: 7th February 2007, 10:07
  5. qsqldatabase does not sense db disconnect
    By rburge in forum Qt Programming
    Replies: 0
    Last Post: 9th March 2006, 18:59

Tags for this Thread

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.