Results 1 to 9 of 9

Thread: QProcess: finished() signal not emitted running Powershell script

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QProcess: finished() signal not emitted running Powershell script

    What if you exchange your external process call with a different one, e.g. running notepad or something like that? Do you get the finished signal when you exit that external program?
    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.


  2. The following user says thank you to wysota for this useful post:

    Laureta (11th January 2015)

  3. #2
    Join Date
    Jan 2015
    Location
    Tremp, Spain
    Posts
    14
    Thanks
    6
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: QProcess: finished() signal not emitted running Powershell script

    Quote Originally Posted by wysota View Post
    What if you exchange your external process call with a different one, e.g. running notepad or something like that? Do you get the finished signal when you exit that external program?
    I have another application that calls mysqldump to backup and restore the database, and I get finished signal.
    Although I don't like, I found a workaround: at the last line of script I write something (e.g. "End") to stdout. Then I test the "end" as follows:

    Qt Code:
    1. connect(proces, SIGNAL(readyReadStandardOutput()), this, SLOT(test()));
    2.  
    3. void Dialog::test() {
    4. qDebug() << proces->readAllStandardOutput(); // "End"
    5. }
    To copy to clipboard, switch view to plain text mode 
    I reviewed all documentation I found about Powershell, including my Holy Bible -I mean Windows 7 Resource Kit (paperback) Perhaps that's one of the Microsoft's undocumented quirks...

    Edit: (3 min. later)
    I found the solution (no Qt problem). Apparently powershell does not run in the same way from the console or when is called from another program (noninteractive). If I add at end of script:

    Get-Process Powershell | Stop-Process
    I Stop * really * powershell and get finished signal, with QProcess::ExitStatus = 0.
    The slot:
    Qt Code:
    1. void Dialog::procState(QProcess::ProcessState estat) {
    2. qDebug() << estat;
    3. }
    To copy to clipboard, switch view to plain text mode 
    now shows the states: 1 (starting), 2 (running) and 0 (not running).

    Thanks to all of you for making me think a little longer.
    Last edited by Laureta; 11th January 2015 at 20:17.

  4. #3
    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: QProcess: finished() signal not emitted running Powershell script

    You might also try the "-NonInteractive" argument to the Powershell.exe and see if that allows the exit.

Similar Threads

  1. QNetworkAccessManager no finished() signal emitted
    By realperson in forum Qt Programming
    Replies: 4
    Last Post: 18th January 2018, 08:42
  2. QProcess finishes but never emits finished signal
    By BettaUseYoNikes in forum Qt Programming
    Replies: 2
    Last Post: 3rd December 2011, 08:01
  3. Running an script using QProcess
    By DiegoTc in forum Newbie
    Replies: 1
    Last Post: 31st December 2010, 18:02
  4. Replies: 0
    Last Post: 24th May 2010, 08:11
  5. QProcess object not emitting finished(int) signal
    By Tiansen in forum Qt Programming
    Replies: 13
    Last Post: 14th November 2008, 12:17

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.